| 59 | .split(" ").map(n => "tok-" + n) |
| 60 | |
| 61 | function highlight(lang, text) { |
| 62 | let result = "", parser = parsers[lang], tree = parser ? parser.parse(text) : Tree.empty |
| 63 | highlightCode(text, tree, classHighlighter, (code, cls) => { |
| 64 | let esc = escape(code) |
| 65 | cls = cls.replace(/([\w-]+)\s*/g, (m, style) => styled.includes(style) ? m : "") |
| 66 | result += cls ? `<span class="${cls}">${esc}</span>` : esc |
| 67 | }, () => result += "\n") |
| 68 | return result |
| 69 | } |
| 70 | |
| 71 | function maybeSplitInlineCode(html) { |
| 72 | if (html.length <= 16) return html |