Coder Social home page Coder Social logo

iq-scm / htmlbeautifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from threedaymonk/htmlbeautifier

0.0 0.0 0.0 172 KB

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.

License: MIT License

Ruby 100.00%

htmlbeautifier's Introduction

HTML Beautifier

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.

What it does

  • Normalises hard tabs to spaces (or vice versa)
  • Removes trailing spaces
  • Indents after opening HTML elements
  • Outdents before closing elements
  • Collapses multiple whitespace
  • Indents after block-opening embedded Ruby (if, do etc.)
  • Outdents before closing Ruby blocks
  • Outdents elsif and then indents again
  • Indents the left-hand margin of JavaScript and CSS blocks to match the indentation level of the code

Usage

From the command line

To update files in-place:

$ htmlbeautifier file1 [file2 ...]

or to operate on standard input and output:

$ htmlbeautifier < input > output

In your code

require 'htmlbeautifier'

beautiful = HtmlBeautifier.beautify(messy)

You can also specify how to indent (the default is two spaces):

beautiful = HtmlBeautifier.beautify(messy, indent: "\t")

Installation

This is a Ruby gem. To install the command-line tool (you may need sudo):

$ gem install htmlbeautifier

To use the gem with Bundler, add to your Gemfile:

gem 'htmlbeautifier'

Contributing

  1. Follow these guidelines when writing commit messages (briefly, the first line should begin with a capital letter, use the imperative mood, be no more than 50 characters, and not end with a period).
  2. Include tests.

htmlbeautifier's People

Contributors

amcvitty avatar chrisberkhout avatar deepakmahakale avatar fukata avatar jeremiemv avatar jirutka avatar masal avatar mkozono avatar mweitzel avatar nruth avatar threedaymonk avatar trendster avatar wonicon 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.