1.0.0 • Published 9 years ago
front-matter-html v1.0.0
front-matter-html
Parse Front Matter from an HTML comment
Installation
npm install front-matter-htmlUsage
const fm = require('front-matter-html');
const html = `<!--
kittens: true
puppies: true
lizards: false
-->
<!doctype html>
<html>
<!-- ... -->
</html>
`;
const content = fm(html);API
fm(html)
Parse YAML Front Matter from an HTML comment at the top of an HTML document.
- html (String): input HTML.
Returns an object with these properties:
- attributes (Object): extracted YAML.
- body (String): HTML without Front Matter comment.
- frontmatter (String): original YAML string.
fm.test(html)
Test if an HTML document contains a Front Matter block within <!-- -->.
Returns true or false.
Local Development
git clone https://github.com/gakimball/front-matter-html
cd front-matter-html
npm install
npm testLicense
MIT © Geoff Kimball
1.0.0
9 years ago