如何更好控制HTML自动缩进?含Tidy工具使用场景
HTML Tidy 属性对齐优化方案
自定义配置文件实现属性对齐
创建一个tidy.config配置文件,写入以下规则:indent-attributes: yes attribute-indent: 4 wrap-attributes: yes wrap-attribute-indent: 4执行命令时指定该配置文件:
tidy -config tidy.config -qni -ashtml index.html -o out.html其中:
indent-attributes: yes开启属性缩进功能attribute-indent: 4设置属性相对于标签名的缩进空格数wrap-attributes: yes强制每个属性单独占用一行wrap-attribute-indent: 4设置换行后属性的缩进量
直接通过命令行参数添加对齐规则
无需配置文件,直接在原有命令中补充属性对齐相关参数:tidy -qni -ashtml -indent-attributes yes -attribute-indent 4 -wrap-attributes yes -wrap-attribute-indent 4 index.html -o out.html版本兼容说明
HTML Tidy 5.6.0完全支持上述参数,且与你当前使用的-qni(安静模式+缩进)参数无冲突,可以直接组合使用。
内容的提问来源于stack exchange,提问作者user3313834
相关产品推荐
相关产品推荐

