UNPKG

js-markdown

Version:
52 lines (44 loc) 1.06 kB
/** * match a footnote * * use an id or number for footnote, syntax like this: * * [^footnote1]: this is a footnote. * [^2]: this is the second footnote. * * you can write it anywhere. * */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; function parse(line, index, lines, renderTree) { var reg = /^\s*\[\^([^\[\]]+)\]:\s*(.+)(?:\n|$)/; var result = line.match(reg); if (!result) { return; } if (renderTree) { if (!renderTree.footnotes) { renderTree.footnotes = []; } renderTree.footnotes.push({ type: 'Footnote', key: result[1], rawValue: result[2] }); } return [null, index]; } function render() { var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; var node = arguments.length > 1 ? arguments[1] : undefined; return "<div class=\"footnotes\"><hr>".concat(node.rawValue || '').concat(data, "</div>"); } var _default = { parse: parse, render: render }; exports["default"] = _default;