tidy

HTML Tidy Project Page

デフォルトが古かったので、portで新しめのものをインストール。


Clean up your Web pages with HTML TIDY

$ tidy -config /path/to/conf file1.html file2.html


微妙に不満だったので力技で修正。

#!/bin/sh
conf='/path/to/conf'
tidy='/path/to/tidy'
$tidy -config $conf $1 |perl -ne 'BEGIN{$lines="";}$lines.=$_;END {$lines =~ s|\n+(\s*<)(?!div)|\n$1|smgx;print $lines;}'

\はバックスラッシュ



HTML Tidy Configuration Options Quick Reference
(よくわからん...)


bare: yesは化ける。

//Character Encoding Options
char-encoding: raw
newline: LF

// HTML, XHTML, XML Options
alt-text: 
//bare: yes
clean: yes
drop-font-tags: yes
drop-proprietary-attributes: yes
input-xml: no
numeric-entities: yes
output-xml: no
output-xhtml: yes
preserve-entities: yes
quote-marks: yes
quote-nbsp: yes
uppercase-tags: no
uppercase-attributes: no

// Diagnostics Options
show-warnings: yes

// Pretty Print Options
break-before-br: no
indent: auto
indent-spaces: 2
markup: yes
wrap: 0

// Miscellaneous Options
quiet: yes