metalsmith-correct-html v1.0.0
metalsmith-correct-html
A metalsmith plugin for correcting HTML syntax.
This plugin corrects HTML syntax (such as missing ending tags). Under the hood metalsmith-correct-html uses jsdom to simply convert the HTML markup into a JSDOM document, and then convert the document back into markup to correct the HTML syntax.
Installation
npm install metalsmith-correct-htmlUsage
To use this plugin, simply add it to the existing plugins in your Metalsmith source file or include it in the Metalsmith JSON file:
JavaScript
const Metalsmith = require('metalsmith');
const correctHtml = require('metalsmith-correct-html');
Metalsmith(__dirname)
.use(correctHtml())
.build((err, files) => {
if (err) { throw err; }
});JSON
{
"plugins": {
"metalsmith-correct-html": {}
}
}Options
You can pass options to metalsmith-correct-html with the Javascript API or CLI. The options are:
- pattern: optional. Only files that match this pattern will be processed. Accepts a string or an array of strings. The default is
**/*.html.
pattern
Only files that match this pattern will be processed. So this Metalsmith JavaScript configuration or metalsmith.json:
JavaScript
const Metalsmith = require('metalsmith');
const correctHtml = require('metalsmith-correct-html');
Metalsmith(__dirname)
.use(correctHtml({
pattern: 'blog/**/*.html',
}))
.build((err, files) => {
if (err) { throw err; }
});JSON
{
"source": "src",
"destination": "build",
"plugins": {
"metalsmith-correct-html": {
"pattern": "blog/**/*.html"
}
}
}Would only process HTML files within the ./src/blog folder, because the pattern is
relative to your source folder. See multimatch
for further details.
License
5 years ago