【问题标题】:How to run Tidy-html5 (aka HTML Tidy) recursively on all html files?如何在所有 html 文件上递归运行 Tidy-html5(又名 HTML Tidy)?
【发布时间】:2018-10-03 22:48:00
【问题描述】:

我想在所有 html 文件(包括子目录中的文件)上递归运行 HTML Tidy(又名 tidy-html5)。虽然tidy -mq ./src/*.html 对 src 目录中的所有 html 文件都有效,但它不能在子目录中运行。

我的html目录结构是这样的,每个目录包含多个html文件:

└── src/
    ├── 2017-12-01-post1/*.html
    ├── 2017-12-15-post2/*.html
    ├── 2018-01-03-post3/*.html
    ├── 2018-04-01-post4/*.html
    └── ... (more dir)

是否可以做类似tidy -mq ./src/**/*.html 的事情? (类似于 Prettier 的工作方式)

【问题讨论】:

    标签: tidy htmltidy


    【解决方案1】:

    我决定像这样使用find 命令(Linux、Mac、*nix、BSD):

    find . -name '*.html' -type f -print -exec tidy -mq '{}' \;
    

    这将在目录中递归搜索所有 HTML 文件并对其执行tidy

    或者,在 Bash 中,使用 shopt -s globstar:

    shopt -s globstar
    tidy -mq **/*.html
    

    在 ZSH 中,它无需任何其他设置即可工作:

    tidy -mq **/*.html
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-03
      • 2017-05-07
      • 2011-04-29
      • 2012-10-03
      • 1970-01-01
      • 2012-11-03
      • 2012-03-17
      • 2011-10-02
      相关资源
      最近更新 更多