I've installed the W3C tidy-html5 bundle here: ~/Library/Application Support/Avian/Pristine Copy/Bundles/tidy-html5
However, when I run the command in Terminal, it doesn't seem to recognize HTML5 tags. It seems like it's probably running the old HTML Tidy method, which only understands XHTML/HTML4.
For example, if I run:
tidy ~/Desktop/tidy-test.html
I get this output:
line 1 column 180 - Error: <aside> is not recognized!
line 1 column 180 - Warning: discarding unexpected <aside>
line 1 column 353 - Error: <section> is not recognized!
line 1 column 353 - Warning: discarding unexpected <section>
line 1 column 418 - Warning: replacing invalid character code 139
line 1 column 419 - Warning: replacing invalid character code 134
line 1 column 421 - Warning: replacing invalid character code 139
line 1 column 422 - Warning: replacing invalid character code 134
line 1 column 424 - Warning: replacing invalid character code 139
line 1 column 425 - Warning: replacing invalid character code 134
line 1 column 427 - Warning: replacing invalid character code 139
line 1 column 428 - Warning: replacing invalid character code 134
line 1 column 430 - Warning: replacing invalid character code 139
line 1 column 431 - Warning: replacing invalid character code 134
line 1 column 432 - Warning: discarding unexpected </section>
line 1 column 443 - Error: <section> is not recognized!
line 1 column 443 - Warning: discarding unexpected <section>
line 1 column 567 - Warning: discarding unexpected </section>
line 1 column 578 - Error: <section> is not recognized!
line 1 column 578 - Warning: discarding unexpected <section>
line 1 column 645 - Warning: discarding unexpected </section>
line 1 column 656 - Warning: discarding unexpected </aside>
line 12 column 4 - Error: <canvas> is not recognized!
line 12 column 4 - Warning: discarding unexpected <canvas>
line 13 column 27 - Warning: discarding unexpected </canvas>
line 13 column 45 - Warning: discarding unexpected </html>
line 1 column 770 - Warning: trimming empty <span>
Info: Document content looks like HTML 4.01 Transitional
Info: No system identifier in emitted doctype
22 warnings, 5 errors were found!
This document has errors that must be fixed before
using HTML Tidy to generate a tidied up version.
Character codes 128 to 159 (U+0080 to U+009F) are not allowed in HTML;
even if they were, they would likely be unprintable control characters.
Tidy assumed you wanted to refer to a character with the same byte value in the
specified encoding and replaced that reference with the Unicode equivalent.
To learn more about HTML Tidy see http://tidy.sourceforge.net
Please send bug reports to html-tidy@w3.org
HTML and CSS specifications are available from http://www.w3.org/
Lobby your company to join W3C, see http://www.w3.org/Consortium
Ideally I would like to be able to just Tidy an entire HTML5 document or selection directly in TextMate, the same way I can now for XHTML. If that's not possible, I'd like to be able to run Tidy on the command line and get back 1. a correctly reformatted/tidied document, and 2. a report of what was done to it.
Assuming you know and use Homebrew on your machine ( OS X )
and have tidy
installed using Homebrew:
$ brew uninstall tidy
$ brew tap homebrew/dupes
$ brew install --HEAD tidy
$ tidy --version
HTML Tidy for HTML5 (experimental) for Mac OS X https://github.com/w3c/tidy- html5/tree/c63cc39
Remarks:
tidy
using Homebrew before. homebrew/dupes
.