22 lines
638 B
JavaScript
22 lines
638 B
JavaScript
import { highlight } from "./codeHighlighter.js"
|
|
|
|
export const markedRenderer = {
|
|
// Rendering of headings (add an anchor above all headings).
|
|
heading(text, level) {
|
|
return `
|
|
<a name="${text.replace(/\s/g, "-")}" data-orig-text="${text}" class="toc-anchor toc-anchor-h${level}"></a>
|
|
<h${level}>
|
|
${text}
|
|
</h${level}>
|
|
`
|
|
},
|
|
|
|
// Render code properly, and syntax highlight it.
|
|
code(code, lang, escaped) {
|
|
return `
|
|
<pre>
|
|
<code class="language-${lang}">${highlight(code, lang)}</code>
|
|
</pre>
|
|
`
|
|
}
|
|
} |