front-matter-html

1.0.0 • Public • Published

front-matter-html

Parse Front Matter from an HTML comment

Travis npm

Installation

npm install front-matter-html

Usage

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 test

License

MIT © Geoff Kimball

Package Sidebar

Install

npm i front-matter-html

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • gakimball