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

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

[ 来源:W3C | 时间:2008年03月17日 | 收藏本文 ] 【
Tidy's Options

To get a list of available options use:

   tidy -help

You may want to run it through more to view the help a page at a time.

   tidy -help | more

Input and Output default to stdin/stdout respectively. Single letter options apart from -f may be combined as in: tidy -f errs.txt -imu foo.html

Using a Configuration File

Tidy now supports a configuration file, and this is now much the most convenient way to configure Tidy. Assuming you have created a config file named "config.txt" (the name doesn't matter), you can instruct Tidy to use it via the command line option -config config.txt, e.g.

   tidy -config config.txt file1.html file2.html

Alternatively, you can name the default config file via the environment variable named "HTML_TIDY". Note this should be the absolute path since you are likely to want to run Tidy in different directories. You can also set a config file at compile time by defining CONFIG_FILE as the path string, see platform.h.

You can now set config options on the command line by preceding the name of the option immediately (no intervening space) by "--", for example:

  tidy --break-before-br true --show-warnings false

The full set of options available on recent versions of HTML Tidy can be found in this Quick Reference maintained as part of the Source Forge HTML Tidy project.

Sample Config File

This is just an example to get you started.

// sample config file for HTML tidy
indent: auto
indent-spaces: 2
wrap: 72
markup: yes
output-xml: no
input-xml: no
show-warnings: yes
numeric-entities: yes
quote-marks: yes
quote-nbsp: yes
quote-ampersand: no
break-before-br: no
uppercase-tags: no
uppercase-attributes: no
char-encoding: latin1
new-inline-tags: cfif, cfelse, math, mroot, 
  mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover,
  munder, mover, mmultiscripts, msup, msub, mtext,
  mprescripts, mtable, mtr, mtd, mth
new-blocklevel-tags: cfoutput, cfquery
new-empty-tags: cfelse

Using Tidy from scripts

If you want to run Tidy from a Perl or other scripting language you may find it of value to inspect the result returned by Tidy when it exits: 0 if everything is fine, 1 if there were warnings and 2 if there were errors. This is an example using Perl:

if (close(TIDY) == 0) {
  my $exitcode = $? >> 8;
  if ($exitcode == 1) {
    printf STDERR "tidy issued warning messages\n";
  } elsif ($exitcode == 2) {
    printf STDERR "tidy issued error messages\n";
  } else {
    die "tidy exited with code: $exitcode\n";
  }
} else {
  printf STDERR "tidy detected no errors\n";
}

Source Code

The latest versions of the source code can be found at the Source Forge developer's site for Tidy, see http://tidy.sourceforge.net.

文章引用自:  http://www.w3.org/People/Raggett/tidy/

 

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

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