Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

comment-meta

hyurl17MITdeprecated0.1.1TypeScript support: included

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

An HTML/Markdown comment metadata parsing tool.

comment, meta

readme

Comment Meta

An HTML/Markdown comment metadata parsing tool.

Example

var meta = require(".").default;
var assert = require("assert");

var html = '<!--\n'
    + 'title: Hello, World!\n'
    + 'author: Ayon Lee\n'
    + 'author email: i@hyurl.com;\n'
    + '-->\n'
    + '<h1>This is a title</h1>\n'
    + '<!-- title: Hello, World!; author: Ayon Lee; author email: i@hyurl.com -->\n'
    + '<!-- This comment will not be parsed -->\n'
    + '<!-- This comment\n'
    + 'will not be parsed as well -->';

var expected = [
    {
        title: "Hello, World!",
        author: "Ayon Lee",
        "author email": "i@hyurl.com"
    },
    {
        title: "Hello, World!",
        author: "Ayon Lee",
        "author email": "i@hyurl.com"
    }
];

assert.deepStrictEqual(meta(html), expected);

console.log("#### OK ####");

Meta Style

This tool allows you setting metadata in HTML/Markdown comments, in the style of <key>: <value>, separated by semicolons (;) or line endings (\n), and parse them into an array of objects stored all key-value pairs. See the above example.