UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

29 lines 809 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeHTML = escapeHTML; exports.escapeNewline = escapeNewline; /** * Escapes HTML special characters in a string. * @param str - The string to escape * @returns The escaped string */ function escapeHTML(str) { return str?.replace(/[&<>"']/g, (tag) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;', }[tag] ?? tag)); } /** * Escapes newline characters in a string (Supports Windows and Unix newlines). * @param str - The string to escape * @returns The escaped string */ function escapeNewline(str) { return str.replace(/([\n\r])/g, (match) => { return match == '\n' ? '\\n' : '\\r'; }); } //# sourceMappingURL=doc-escape.js.map