31 lines
790 B
JavaScript
31 lines
790 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>
|
|
`
|
|
},
|
|
|
|
table(header, body) {
|
|
return `
|
|
<table>
|
|
${header}
|
|
${body}
|
|
</table>
|
|
`
|
|
}
|
|
} |