diff --git a/Gemfile b/Gemfile index 2c0ac91d55c9..135694ee65f9 100644 --- a/Gemfile +++ b/Gemfile @@ -4,5 +4,5 @@ group :development, :test do gem 'jekyll', '~> 3.6.0' gem 'jekyll-redirect-from', '~> 0.12.1' gem 'jekyll-sitemap', '~> 1.1.1' - gem 'jekyll-toc', '~> 0.3.0' + gem 'jekyll-toc', '~> 0.4.0.rc2' end diff --git a/Gemfile.lock b/Gemfile.lock index 38c6658d6127..0be2f9d180ba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,7 +24,7 @@ GEM sass (~> 3.4) jekyll-sitemap (1.1.1) jekyll (~> 3.3) - jekyll-toc (0.3.0) + jekyll-toc (0.4.0.rc2) nokogiri (~> 1.6) jekyll-watch (1.5.0) listen (~> 3.0, < 3.1) @@ -61,7 +61,7 @@ DEPENDENCIES jekyll (~> 3.6.0) jekyll-redirect-from (~> 0.12.1) jekyll-sitemap (~> 1.1.1) - jekyll-toc (~> 0.3.0) + jekyll-toc (~> 0.4.0.rc2) BUNDLED WITH 1.15.4 diff --git a/build/htmllint.js b/build/htmllint.js new file mode 100644 index 000000000000..f69d80141184 --- /dev/null +++ b/build/htmllint.js @@ -0,0 +1,46 @@ +#!/usr/bin/env node + +/*! + * Script to run vnu-jar if Java is available. + * Copyright 2017 The Bootstrap Authors + * Copyright 2017 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +'use strict' + +const childProcess = require('child_process') +const vnu = require('vnu-jar') + +childProcess.exec('java -version', function (error) { + if (error) { + console.error('Skipping HTML lint test; Java is missing.') + return + } + + const ignores = [ + 'Attribute “autocomplete” is only allowed when the input type is “color”, “date”, “datetime-local”, “email”, “hidden”, “month”, “number”, “password”, “range”, “search”, “tel”, “text”, “time”, “url”, or “week”.', + 'Attribute “autocomplete” not allowed on element “button” at this point.', + 'Attribute “title” not allowed on element “circle” at this point.', + 'Bad value “tablist” for attribute “role” on element “nav”.', + 'Element “img” is missing required attribute “src”.', + 'Element “legend” not allowed as child of element “div” in this context.*' + ].join('|') + + const args = [ + '-jar', + vnu, + '--asciiquotes', + '--errors-only', + '--skip-non-html', + `--filterpattern "${ignores}"`, + '_gh_pages/', + 'js/tests/' + ] + + return childProcess.spawn('java', args, { + shell: true, + stdio: 'inherit' + }) + .on('exit', process.exit) +}) diff --git a/package-lock.json b/package-lock.json index 4fec5a068c58..b9ac483fe647 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6872,6 +6872,12 @@ "extsprintf": "1.3.0" } }, + "vnu-jar": { + "version": "17.11.1", + "resolved": "https://registry.npmjs.org/vnu-jar/-/vnu-jar-17.11.1.tgz", + "integrity": "sha512-GtlIJyyBQzVw4WCn5ZIsv/lRBqr02vHzr2RofljEURqsKy/CwUmVRjEJJL/d4nou5+B3rpaf3D1scAdQGOX1tA==", + "dev": true + }, "walk-sync": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-0.3.1.tgz", diff --git a/package.json b/package.json index 0b4958ff58ca..6a968518cece 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "docs-compile": "bundle exec jekyll build", "postdocs-compile": "npm run docs-workbox-precache", "docs-github": "shx echo \"github: true\" > twbsconfig.yml && npm run docs-compile -- --config _config.yml,twbsconfig.yml && shx rm ./twbsconfig.yml", - "docs-lint": "htmllint --rc build/.htmllintrc \"_gh_pages/**/*.html\" \"js/tests/**/*.html\"", + "docs-lint": "htmllint --rc build/.htmllintrc \"_gh_pages/**/*.html\" \"js/tests/**/*.html\" && node build/htmllint.js", "docs-serve": "bundle exec jekyll serve", "docs-upload-preview": "build/upload-preview.sh", "docs-workbox-precache": "node build/workbox.js", @@ -111,6 +111,7 @@ "stylelint-order": "^0.7.0", "stylelint-scss": "^2.1.0", "uglify-js": "^3.0.24", + "vnu-jar": "^17.11.1", "workbox-build": "^2.0.1" }, "engines": {