UNPKG

@antora/assembler

Version:

A JavaScript library that merges AsciiDoc content from multiple pages in an Antora site into assembly files and delegates to an exporter to convert those files to another format, such as PDF.

14 lines (10 loc) 383 B
'use strict' const XML_TAG_RX = /<[^>]+>/g const XML_SPECIAL_CHARS = { '&lt;': '<', '&gt;': '>', '&amp;': '&' } const XML_SPECIAL_CHARS_RX = /&(?:[lg]t|amp);/g function sanitize (str) { if (~str.indexOf('<')) str = str.replace(XML_TAG_RX, '') if (~str.indexOf('&')) str = str.replace(XML_SPECIAL_CHARS_RX, (m) => XML_SPECIAL_CHARS[m]) return str } module.exports = sanitize