@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
62 lines • 1.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeMarkdown = escapeMarkdown;
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;
}
/**
* Converts mermaid code (potentially produced by {@link graphToMermaid}) to an url that presents the graph in the mermaid editor.
*
* @param code - code to convert
*/
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