UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

68 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.escapeMarkdown = escapeMarkdown; exports.escapeId = escapeId; exports.mermaidCodeToUrl = mermaidCodeToUrl; const replacements = { // keep newlines '\\n': '\n', '`': '#96;', '[': '#91;', ']': '#93;', '<': '#60;', '>': '#62;', '*': '#42;', '+': '#43;', '-': '#45;', '"': '#34;', '\\': '#92;', '_': '#95;', '{': '#123;', '}': '#125;', '&': '#38;', '\'': '#39;', ':': '#58;', '∨': '#8744;', '∧': '#8743;', '¬': '#172;', '→': '#8594;', '↔': '#8596;', '⇒': '#8658;', '⇔': '#8660;', '∀': '#8704;', '∃': '#8707;', '∈': '#8712;', '∉': '#8713;', '∋': '#8715;', '∌': '#8716;', '∩': '#8745;', '∪': '#8746;', '∫': '#8747;', '⊕': '#8853;', }; function escapeMarkdown(text) { for (const [key, value] of Object.entries(replacements)) { text = text.replaceAll(key, value); } return text; } function escapeId(text) { text = String(text).replace(/[^a-zA-Z0-9:-]/g, '_'); return text; } /** * Converts mermaid code (potentially produced by {@link graphToMermaid}) to an url that presents the graph in the mermaid editor. * * @param code - code to convert * @param edit - if true, the url will point to the editor, otherwise it will point to the viewer */ function mermaidCodeToUrl(code, edit = false) { const obj = { code, mermaid: { autoSync: true } }; return `https://mermaid.live/${edit ? 'edit' : 'view'}#base64:${Buffer.from(JSON.stringify(obj)).toString('base64')}`; } //# sourceMappingURL=mermaid.js.map