如何通过 TextMate 或命令行在 Mac OS 上使用 W3C tidy-html5 包?

sui*_*ris 5 html validation textmate htmltidy textmatebundles

我在这里安装了 W3C tidy-html5 包:~/Library/Application Support/Avian/Pristine Copy/Bundles/tidy-html5

但是,当我在终端中运行该命令时,它似乎无法识别 HTML5 标签。看起来它可能正在运行旧的 HTML Tidy 方法,它只能理解 XHTML/HTML4。

例如,如果我运行:

tidy ~/Desktop/tidy-test.html
Run Code Online (Sandbox Code Playgroud)

我得到这个输出:

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
Run Code Online (Sandbox Code Playgroud)

理想情况下,我希望能够直接在 TextMate 中整理整个 HTML5 文档或选择,就像我现在对 XHTML 所做的一样。如果这是不可能的,我希望能够在命令行上运行 Tidy 并返回 1. 正确重新格式化/整理的文档,以及 2. 对其所做操作的报告。

Web*_*ion 4

假设您了解并在您的计算机 ( OS X ) 上使用 Homebrew
,并且已tidy使用 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
Run Code Online (Sandbox Code Playgroud)

评论:

  • tidy如果您之前没有使用 Homebrew安装,请跳过第一步。
  • 如果您已经点击了,请跳过第二步homebrew/dupes