Giter Site home page Giter Site logo

bsautifier's Introduction

BSAutifier

javascript html beautify (indent formatting) module.

when our html look like that:

<div class="container my_container">
  <div class="row"> <div class="content"> Content beside tags - it text<div class="content">
      <h1>Simple goods for you
  <i>


extra short tag name example



  </i>
    </h1>
  </div>
      <div data-source="/partials/our_contacts">
      Simple <%= 'we need't erb tags supprt! %> raw text content
    </div>
    <img src="fake"/> <!-- self closed tag example -->

    <div data-source="/partials/link_us">
    
    </div>
       <input id="feedback_name" class="form-control" title="this field must contain your name" name="feedback[name]" pattern="[a-zA-Z ]+" required="required" type="text" placeholder="Name" /><input id="feedback_e_mail" class="form-control" title="This field must contain valid email" name="feedback[e_mail]" pattern=".+@.+" type="e_mail" placeholder="E-mail" /><input id="feedback_phone" class="form-control" title="This field must contain your phone number" name="feedback[phone]" pattern="+?[()- 0-9]{6,13}" type="phone" placeholder="Phone" />
  <div data-source="/partials/subscribe_service">
</div>
<div id="text" class="col-sm-6 bf_user_txt">
      <textarea id="feedback_text" class="form-control" title="Write message for manager here" name="feedback[text]" placeholder="Message text">
      </textarea>
  </div>
</div>
<div data-source="/partials/updates">
</div>
</div>
</div>

we would to come it to more pretty format. BSAutifier do it and you went:

<div class="container my_container">
  <div class="row">
    <div class="content">
      Content beside tags - it text
      <div class="content">
        <h1>
          Simple goods for you
          <i>
            extra short tag name example
          </i>
        </h1>
      </div>
      <div data-source="/partials/our_contacts">
        Simple<%= 'we need't erb tags supprt! %>raw text content
      </div>
      <img src="fake"/>
      <!-- self closed tag example -->
      <div data-source="/partials/link_us"></div>
      <input id="feedback_name" class="form-control" title="this field must contain your name" name="feedback[name]" pattern="[a-zA-Z ]+" required="required" type="text" placeholder="Name" />
      <input id="feedback_e_mail" class="form-control" title="This field must contain valid email" name="feedback[e_mail]" pattern=".+@.+" type="e_mail" placeholder="E-mail" />
      <input id="feedback_phone" class="form-control" title="This field must contain your phone number" name="feedback[phone]" pattern="+?[()- 0-9]{6,13}" type="phone" placeholder="Phone" />
      <div data-source="/partials/subscribe_service"></div>
      <div id="text" class="col-sm-6 bf_user_txt">
        <textarea id="feedback_text" class="form-control" title="Write message for manager here" name="feedback[text]" placeholder="Message text"></textarea>
      </div>
    </div>
    <div data-source="/partials/updates"></div>
  </div>
</div>

Installing and using:

  1. Include js:

    First include module to your page:

    <script src="BSAutifier.js"></script>
    • it's all!
  2. Initialize:

    You can initialize BSAutifier object in javascript:

    1. with params:

      html_beautifier = new BSAutifier({
        'tags' : {
          'opening': /<[a-z][^<]*?[^\/\%]>|<[a-z]>/im,
          'closing': /<\/[^>]+>/m,
          'self_closing': /<[^!][^>]+?\/>/m
        },
        'tabSize': 4,
        'line_end_char': '\n'
      })
    2. within params:

      html_beautifier = new BSAutifier()
  3. Use:

    use initialized BSAutifier object instance to beautify html:

    beauty_html_text = html_beautifier.beautify(text_to_beautify);

bsautifier's People

Contributors

bsa7 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.