← 返回命令列表

Linux command

tidy 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Clean HTML file

tidy [input.html]

Write to file

tidy -o [output.html] [input.html]

Modify in place

tidy -m [file.html]

Convert to XHTML

tidy -asxhtml [input.html]

Show only errors

tidy -e [input.html]

Indent output

tidy -i [input.html]

Quiet mode

tidy -q [input.html]

Wrap at column

tidy -w [80] [input.html]

说明

tidy validates and reformats HTML documents, detecting markup errors such as missing closing tags, improper nesting, and deprecated elements. It can automatically fix many common problems while producing consistently formatted output with standardized indentation and line wrapping. The tool can convert HTML to XHTML (-asxhtml) for stricter XML-compliant output, or reformat in place with -m. Error-only mode (-e) reports problems without modifying the document, useful for quick validation checks. Output wrapping width is configurable with the -w flag.

参数

-o _FILE_
Output file.
-m, --modify
Modify in place.
-i, --indent
Indent content.
-e, --errors
Show errors only.
-q, --quiet
Quiet mode.
-w _N_, --wrap _N_
Wrap at column.
-asxhtml
Output as XHTML.
-ashtml
Output as HTML.
--indent-spaces _N_
Spaces per indent.

FAQ

What is the tidy command used for?

tidy validates and reformats HTML documents, detecting markup errors such as missing closing tags, improper nesting, and deprecated elements. It can automatically fix many common problems while producing consistently formatted output with standardized indentation and line wrapping. The tool can convert HTML to XHTML (-asxhtml) for stricter XML-compliant output, or reformat in place with -m. Error-only mode (-e) reports problems without modifying the document, useful for quick validation checks. Output wrapping width is configurable with the -w flag.

How do I run a basic tidy example?

Run `tidy [input.html]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _FILE_ do in tidy?

Output file.