当前位置:甜馍馍地理信息网 >> 网站开发 >> 综合知识 >> 正文 >>  [阅读资讯:HTML文档规范化简洁化 HTML TIDY介绍及使用]

HTML文档规范化简洁化 HTML TIDY介绍及使用

[ 来源:W3C | 时间:2008年03月17日 | 收藏本文 ] 【
Indenting the content does increase the size of the file, so you may prefer Tidy's default style:

 <html>
 <head>
 <title>Test document</title>
 </head>
 <body>
 <p>para which has enough text to cause a line break,
 and so test the wrapping mechanism for long lines.</p>
 <pre>This is
 <em>genuine
       preformatted</em>
    text
 </pre>
 <ul>
 <li>1st list item </li>
 <li>2nd list item</li>
 </ul>
 <!-- end comment -->
 </body>
 </html>

How to run tidy

   tidy [[options] filename]*

HTML tidy is not (yet) a Windows program. If you run tidy without any arguments, it will just sit there waiting to read markup on the stdin stream. Tidy's input and output default to stdin and stdout respectively. Errors are written to stderr but can be redirected to a file with the -f filename option.

I generally use the -m option to get tidy to update the original file, and if the file is particularly bad I also use the -f option to write the errors to a file to make it easier to review them. Tidy supports a small set of character encoding options. The default is ASCII, which makes it easy to edit markup in regular text editors.

For instance:

   tidy -f errs.txt -m index.html

which runs tidy on the file "index.html" updating it in place and writing the error messages to the file "errs.txt". Its a good idea to save your work before tidying it, as with all complex software, tidy may have bugs. If you find any please let me know!

Thanks to Jacek Niedziela, The Win32 executable for tidy is now able to use wild cards in filenames. This utilizes the setargv library supplied with VC++.

Tidy writes errors to stderr, and won't be paused by the more command. A work around is to redirect stderr to stdout as follows. This works on Unix and Windows NT, but not on other platforms. My thanks to Markus Wolf for this tip!

   tidy file.html 2>&1 | more

上一页      下一页
本文共 6 页,第  [1]  [2]  [3]  [4]  [5]  [6]  页

【推荐本文】 【打印本页】 【返回顶部
最新文章
推荐文章