UNPKG

@antora/assembler

Version:

An extension library for Antora that assembles content from multiple pages into a single AsciiDoc file to converted and publish.

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