mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 20:20:21 +01:00
29 lines
501 B
JavaScript
29 lines
501 B
JavaScript
const TAGNAME = "PRE";
|
|
const state = {
|
|
activeBlock: null,
|
|
languages: [],
|
|
};
|
|
function createCodeBlock(content) {
|
|
const pre = document.createElement(TAGNAME);
|
|
pre.spellcheck = false;
|
|
pre.classList.add("hljs");
|
|
pre.innerHTML = newlineToBR(content);
|
|
return pre;
|
|
}
|
|
|
|
function isCodeBlock(node) {
|
|
return node.closest(TAGNAME);
|
|
}
|
|
|
|
function newlineToBR(html) {
|
|
return html.replace(/\n/gm, "<br>");
|
|
}
|
|
|
|
module.exports = {
|
|
newlineToBR,
|
|
createCodeBlock,
|
|
isCodeBlock,
|
|
TAGNAME,
|
|
state,
|
|
};
|