How to use the parse5/lib/serializer/index.escapeString function in parse5

To help you get started, we’ve selected a few parse5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webschik / ng2react-builder / src / serializer / serialize-template.ts View on Github external
function wrapAttrValue (attrValue: string) {
    if (attrValue[0] === doubleQuote && attrValue.slice(-1) === doubleQuote) {
        return attrValue;
    }

    return doubleQuote + Serializer.escapeString(attrValue, true) + doubleQuote;
}
github webschik / ng2react-builder / src / serializer / serialize-template.ts View on Github external
serializer._serializeTextNode = function (node: AST.HtmlParser2.TextNode) {
        const content: string = this.treeAdapter.getTextNodeContent(node);
        const parent: AST.HtmlParser2.TextNode = this.treeAdapter.getParentNode(node);
        let parentTn: string = void 0;

        if (parent && this.treeAdapter.isElementNode(parent)) {
            parentTn = this.treeAdapter.getTagName(parent);
        }

        if (parentTn === $.STYLE || parentTn === $.SCRIPT || parentTn === $.XMP || parentTn === $.IFRAME ||
            parentTn === $.NOEMBED || parentTn === $.NOFRAMES || parentTn === $.PLAINTEXT || parentTn === $.NOSCRIPT) {

            this.html += `${ reactInterpolation.startSymbol }\`${ content }\`${ reactInterpolation.endSymbol }`;
        } else {
            const escapedContent: string = Serializer.escapeString(content, false);

            this.html += escapedContent && interpolate(ngParser, escapedContent, transformOptions) || '';
        }
    };