UNPKG

@connectv/marked

Version:
31 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var extract_comp_props_1 = require("./util/extract-comp-props"); function quotedComponents(map) { return function (_, renderer, content) { var _a; var ref = renderer.create("marker", null, content); if ((_a = ref.childNodes[0].textContent) === null || _a === void 0 ? void 0 : _a.startsWith(':')) { var parts = ref.childNodes[0].textContent.substr(1).split(' '); var name_1 = parts[0]; if (name_1 in map) { var Comp = map[name_1]; var props = extract_comp_props_1.extractCompProps(parts.slice(1).join(' ')); var children_1 = []; ref.childNodes.forEach(function (child, index) { if (index >= 1) children_1.push(child); }); return renderer.create(Comp, props, children_1); } else { throw new Error('Unrecognized Quoted Component:: ' + name_1); } } else { var children_2 = []; ref.childNodes.forEach(function (child) { return children_2.push(child); }); return renderer.create("blockquote", null, children_2); } }; } exports.quotedComponents = quotedComponents; //# sourceMappingURL=quote-comp.js.map