tidy试用

来源:互联网 发布:河北人怎么样知乎 编辑:程序博客网 时间:2024/05/01 08:04

Tidy是一个把HTML标准化的工具,可以在http://tidy.sourceforge.net/上下载

下了个DOS版本用了下,

在命令行输入tidy -f errs.txt -m hy.htm

-f 代表日志文件是errs.txt,如果没有则创建,-m hy.htm表示要进行标准化的文件,转换后会覆盖掉原来的hy.htm),

转换后打开发现hy.htm中的汉字变成乱码了,google search了一下,呵呵,发现原来可以加个config文件配置编码类型,把config.txt放在相应的目录下,然后再次运行

tidy -f errs.txt -config config.txt -m hy.htm,用IE打开后中文正确显示

(实际中遇到一个问题-config config.txt只能放在-m hy.htm之前,否则转换后仍然是乱码

下面是从http://tidy.sourceforge.net/docs/quickref.html下载的config.txt,把char-encoding: latin1改成char-encoding: raw就可解决乱码问题

// 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

 

 

 
原创粉丝点击