@eaglesong/task-panorama
Version:
Eaglesong task for Panorama
24 lines • 899 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
const xmlCommentRegex = /^<!--(.*?)-->$/s;
exports.banTextNodes = (context) => tree => {
tree.match(/^\s*\S/, node => {
const content = node.trim();
if (xmlCommentRegex.test(content))
return node;
context.emitError(new Error(`Text node '${content}' is not allowed.`));
const xmlContent = lodash_1.default.escape(content).replace(/\\/g, '\\\\\\\\');
return {
attrs: {
style: 'color: red; font-size: 32px;',
text: `Error: text node '${xmlContent}' is not allowed.`,
},
content: [],
tag: 'Label',
};
});
return tree;
};
//# sourceMappingURL=posthtml-plugin-ban-text-nodes.js.map
;