命令行 HTML 漂亮打印机:使凌乱的 HTML 可读
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2191989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A command-line HTML pretty-printer: Making messy HTML readable
提问by knorv
I'm looking for recommendations for HTML pretty printers which fulfill the following requirements:
我正在寻找符合以下要求的 HTML 漂亮打印机的建议:
- Takes HTML as input, and then output a nicely formatted/correctly indented but "graphically equivalent" version of the given input HTML.
- Must support command-line operation.
- Must be open-source and run under Linux.
- 将 HTML 作为输入,然后输出给定输入 HTML 的格式良好/缩进正确但“图形等效”的版本。
- 必须支持命令行操作。
- 必须是开源的并在 Linux 下运行。
采纳答案by jonjbar
Have a look at the HTML Tidy Project: http://www.html-tidy.org/
看看 HTML Tidy 项目:http: //www.html-tidy.org/
The granddaddy of HTML tools, with support for modern standards.
HTML 工具的鼻祖,支持现代标准。
There used to be a fork called tidy-html5 which since became the official thing. Here is its GitHub repository.
曾经有一个名为 tidy-html5 的叉子,它后来成为官方的东西。这是它的GitHub 存储库。
Tidy is a console application for Mac OS X, Linux, Windows, UNIX, and more. It corrects and cleans up HTML and XML documents by fixing markup errors and upgrading legacy code to modern standards.
Tidy 是适用于 Mac OS X、Linux、Windows、UNIX 等的控制台应用程序。它通过修复标记错误和将遗留代码升级到现代标准来纠正和清理 HTML 和 XML 文档。
For your needs, here is the command line to call Tidy:
根据您的需要,这里是调用 Tidy 的命令行:
tidy inputfile.html
回答by Paul Brit
Update 2018:The homebrew/dupes
is now deprecated, tidy-html5 may be directly installed.
更新2018:在homebrew/dupes
现在已经废弃,整洁,HTML5可以直接安装。
brew install tidy-html5
Original reply:
原回复:
Tidy
from OS X doesn't support HTML5
. But there is experimental branch on Github
which does.
Tidy
从 OS X 不支持HTML5
. 但是有一个实验分支Github
。
To get it:
为拿到它,为实现它:
brew tap homebrew/dupes
brew install tidy --HEAD
brew untap homebrew/dupes
That's it! Have fun!
就是这样!玩得开心!
回答by zb226
To have an updated, OS-agnostic answer to this question:
要对此问题提供更新的、与操作系统无关的答案:
While the originalHTMLTidyproject has been dormant for over 6 years, a "W3C Community & Business group"that goes by the name "HTML Tidy Advocacy Community Group (HTACG)"has now begun to continue its development, with the goal of making it fully HTML5-compatible. The group was formed in January 2015 and although they describe the current state as "work in progress", binaries are already available for download.
虽然最初的HTMLTidy项目已经休眠了 6 年多,但一个名为“HTML Tidy Advocacy Community Group (HTACG)”的“W3C Community & Business group”现在已经开始继续发展,其目标是使完全兼容 HTML5。该小组成立于 2015 年 1 月,尽管他们将当前状态描述为“正在进行中”,但二进制文件已经可供下载。
- Project homepage: http://www.html-tidy.org/
- Group page at W3C: https://www.w3.org/community/htacg/
- Github repository: https://github.com/htacg/tidy-html5
- Binary downloads: http://www.htacg.org/binaries/
- 项目主页:http: //www.html-tidy.org/
- W3C 的小组页面:https: //www.w3.org/community/htacg/
- Github 存储库:https: //github.com/htacg/tidy-html5
- 二进制下载:http: //www.htacg.org/binaries/
回答by Dave Newton
Just a late followup on an OT question.
只是对 OT 问题的迟到跟进。
Homebrew has a tidy-html5
installed as you'd expect.
Homebrewtidy-html5
如您所愿安装了。
It's linked up as tidy5
.
它链接为tidy5
.