Use HTML Tidy to just indent HTML code?

后端 未结 6 1764
离开以前
离开以前 2020-12-13 10:03

Is it possible to use HTML Tidy to just indent HTML code?

Sample Code

6条回答
  •  情深已故
    2020-12-13 10:19

    Use the indent, tidy-mark, and quiet options:

    tidy \
      -indent \
      --indent-spaces 2 \
      -quiet \
      --tidy-mark no \
      index.html
    

    Or, using a config file rather than command-line options:

    indent: auto
    indent-spaces: 2
    quiet: yes
    tidy-mark: no
    

    Name it tidy_config.txt and save it the same directory as the .html file. Run it like this:

    tidy -config tidy_config.txt index.html
    

    For more customization, use the tidy man page to find other relevant options such as markup: no or force-output: yes.

提交回复
热议问题