export const toHtml = (markdown) => { const symbols = toSymbols(markdown); const html = []; symbols.forEach((s) => html.push(renderers.find((r) => r.key === s.key).render(s)) ); return `
${html.join("\r\n")}
`; }; const toSymbols = (markdown) => { const symbols = []; if (heading.symbols.some((s) => markdown.includes(s))) { const symbol = Object.assign({}, heading); symbol.text = markdown; symbols.push(symbol); } return symbols; }; const heading = { key: "heading", level: 1, multiLine: false, symbols: ["#", "##", "###", "####", "#####", "######"], text: "", children: [], }; const renderers = [ { key: "heading", render: (symbol) => { return `

${symbol.text}

`; }, }, ];