确认HTML5牛排
html5validator的Python项目详细描述
^{tt1}$ is a command line tool that tests files for HTML5 validity. This was written with static site generators like Jekyll and Pelican in mind. Dynamic html content (for example from JS template engines) can be crawled (e.g. with localcrawl) and then validated.
安装
此模块需要Python2.7、3.4、3.5或3.6以及Java8(^{TT2}$或^{TT3}$)。 使用pip install html5validator安装并使用
html5validator --root _build/
验证_build目录中的所有HTML文件。 运行html5validator --help查看命令行选项列表:
此模块使用validator.nu backend 它是用Java编写的。因此,Java运行时环境必须 在您的系统上可用。因为版本是0.2,所以需要Java 8。
检查css/svg
html5validator --root _build/ --also-check-css
# checking only CSS
html5validator --root _build/ --skip-non-css
将css替换为svg,以便使用SVG文件执行类似的行为。
与Circleci 1.0集成
创建一个circle.yml文件:
machine:java:version:openjdk8dependencies:pre:-sudo pip install html5validatortest:override:-html5validator --root _build/
在存储库中使用静态HTML文件,并在每个 git push。
与Circleci 2.0集成
简化示例circle.yml文件来自 pelican-jsmath:
version:2jobs:test-3.6:docker:-image:python:3.6-stretchsteps:-run:name:install Javacommand:apt-get update && apt-get install -y openjdk-8-jre-checkout-run:name:installcommand:pip install '.[test]'-run:name:generate htmlworking_directory:test/example_sitecommand:pelican content -s pelicanconf.py-run:name:validate htmlcommand:html5validator --root test/example_site/outputworkflows:version:2build_and_test:jobs:-test-3.6
与Travisci集成
创建一个.travis.yml文件。这是一个python项目的示例:
language:pythonpython:-"2.7"addons:apt:packages:-openjdk-8-jre# install Java8 as required by vnu.jarbranches:only:-gh-pagesinstall:-pip install html5validatorscript:html5validator --root _build/
这是Java项目的一个示例:
language:javajdk:-oraclejdk8# vnu.jar requires Java 8branches:only:-gh-pagesinstall:-pip install --user html5validatorscript:html5validator --root _build/
使用修复html5validator版本 pip install --userhtml5validator==<version number>。
您还可以将其用于用户页面(形式为<username>.github.io的存储库) HTML文件在主分支中的位置。您只需删除:
branches:only:-gh-pages
来自.travis.yml。我在用这个 my own user page。
与代码集成
将此行添加到Setup Commands:
jdk_switcher use oraclejdk8pip install html5validator
这是ruby项目的一个例子:
rvm use 2.2.0 --installbundle installbundle updateexport RAILS_ENV=testjdk_switcher use oraclejdk8pip install html5validator
技术说明
- 如果您已经在使用grunt,可以考虑使用 grunt-html改为grunt的插件。
- 对angular.js应用程序使用--ignore-re 'Attribute "ng-[a-z-]+" not allowed'。
- 多忽略示例:html5validator --root tests/multiple_ignores/ --ignore-re 'Attribute "ng-[a-z-]+" not allowed' 'Start tag seen without seeing a doctype first'
更改日志
使用pip install html5validator==0.1.14安装特定版本,例如0.1.14。
- master
- 0.3.1(2018-06-01)
- 将vnu jar更新到18.3.0
- 将剩余的命令行选项传递给vnu.jar
- 允许匹配多个文件模式,例如--match *.html *.css
- 0.3.0(2018-01-21)
- 将vnu jar更新至17.11.1
- 支持文件的显式列表:html5validator file1.html file2.html
- 新的命令行选项:--no-langdetect,--format
- --show-warningsflag的新测试
- 重构的内部api <检查>是否存在Java < > >
- 错误修复:拆分java和vnu.jar命令行选项
- 0.2.8(2017-09-08)
- 将vnu jar更新到17.9.0
- 禁止JDK发出有关已拾取环境变量的警告
- 0.2.7(2017-04-09)
- 将vnu jar更新到17.3.0
- lint python代码
- 0.2.2(2016-04-30)
- vnu.jar更新为16.3.3
- 0.2.1(2016-01-25)
- --ignore,--ignore-re:忽略包含确切模式或 匹配正则表达式(从版本0.1.14迁移:将--ignore替换为--ignore-re)
- 卷曲引号和直引号现在可以互换使用
- 更改Java堆栈大小处理(引入了新的命令行选项-l、-ll和-lll)
- 将vnu.jar更新到16.1.1(现在需要Java 8)
- 0.1.14(2015-10-09)
- 更改文本编码处理
- 添加命令行参数--log和--version
- 0.1.12(2015-05-07)
- 记录如何指定要忽略的多个正则表达式
- 添加--ignore作为命令行参数。接受正则表达式 对于应该忽略的警告和错误。
- 0.1.9(2015-03-02)