HTML command line pretty-print: creating dirty HTML-readable

I am looking for recommendations for good HTML printers that meet the following requirements:

  • Accepts HTML as input, and then outputs a well-formatted / correctly indented, but "graphically equivalent" version of the given input HTML.
  • It is necessary to support work on the command line.
  • It must be open source and work under Linux.
+69
html pretty-print tidy
Feb 03 '10 at 13:00
source share
5 answers

Take a look at the HTML Tidy Project: http://www.html-tidy.org/

The grandfather of HTML tools, with support for modern standards.

There used to be a fork called tidy-html5, which has since become official. Here is his GitHub repository .

Tidy is a console application for Mac OS X, Linux, Windows, UNIX, and many others. It corrects and cleans up HTML and XML documents by correcting markup errors and updating legacy code to modern standards.

For your needs, here is the command line for calling Tidy:

tidy inputfile.html 
+69
Feb 03 '10 at 13:08
source share

Update 2018: homebrew/dupes deprecated, tidy-html5 can be installed directly.

 brew install tidy-html5 



Original answer:

Tidy from OS X does not support HTML5 . But there is an experimental branch on Github that does.

To get this:

  brew tap homebrew/dupes brew install tidy --HEAD brew untap homebrew/dupes 

It! Have some fun!

+8
Jul 01 '13 at 12:32
source share

I think HTML tidy is one of the home names in this field.

+2
Feb 03 '10 at 13:05
source share

To update, an OS-agnostic answer to this question:

While the original HTMLTidy Project has been dormant for over 6 years , the W3C Community and Business group which goes under the name "HTML Tidy Advocacy Community Group (HTACG)" has now begun to continue its development in order to make it fully HTML5 -Compatible. The group was formed in January 2015, and although they describe the current status as "work in progress", binary files are already available for download.

+2
Aug 6 '15 at 13:21
source share

A simple review of the OT issue.

Homebrew has tidy-html5 installed as you would expect.

It is tied as tidy5 .

0
Jun 09 '15 at 14:10
source share



All Articles