Htmlbeautifier

screenshot of Htmlbeautifier

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

Overview

HTML Beautifier is a tool designed to normalize and beautify HTML code, particularly useful for tidying up Rails templates. It can also handle embedded Ruby code within the HTML. This Ruby gem offers both a command-line tool and a library for incorporating the beautifying functionality into your code.

Features

  • Normalization: Converts hard tabs to spaces or vice versa, removing trailing spaces and collapsing multiple whitespaces.
  • Indentation: Indents after opening HTML elements, block-opening embedded Ruby (if, do, etc.), and left-hand margins of JavaScript and CSS blocks.
  • Outdentation: Outdents before closing elements, Ruby blocks, elsif, and then re-indents as necessary.

Summary

HTML Beautifier is a versatile tool for normalizing and beautifying HTML code. It offers features like indentation, outdentation, and normalization of whitespace to improve the readability and organization of HTML and embedded Ruby code. It can be easily installed as a Ruby gem and used via the command line or embedded into your own code.