Customize TeX renderer
Less than 1 minute...
This cookbook guides you on how to add your own
@waline/client
provides the texRenderer
function. The client will pass whether in display mode and the original
A Example Using KaTeX
For KaTeX options, see KaTeX API.
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Waline highlighter case</title>
<link
rel="stylesheet"
href="https://unpkg.com/@waline/client@v3/dist/waline.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/katex@v0.16/dist/katex.min.css"
/>
</head>
<body>
<div id="waline" style="max-width: 800px; margin: 0 auto"></div>
<script type="module">
import { init } from '"https://unpkg.com/@waline/client@v3/dist/waline.js"';
import katex from 'https://unpkg.com/katex@0.16/dist/katex.mjs';
init({
el: '#waline',
serverURL: 'https://waline.vercel.app',
path: '/',
lang: 'en-US',
texRenderer: (blockMode, tex) =>
katex.renderToString(tex, {
displayMode: blockMode,
throwOnError: false,
}),
});
</script>
</body>
</html>
A case using MathJax
For MathJax options, see MathJax API.
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Waline highlighter case</title>
<link
rel="stylesheet"
href="https://unpkg.com/@waline/client@v3/dist/waline.css"
/>
<script src="https://unpkg.com/mathjax@v3/es5/tex-svg.js"></script>
</head>
<body>
<div id="waline" style="max-width: 800px; margin: 0 auto"></div>
<script type="module">
import { init } from '"https://unpkg.com/@waline/client@v3/dist/waline.js"';
init({
el: '#waline',
serverURL: 'https://waline.vercel.app',
path: '/',
lang: 'en-US',
texRenderer: (blockMode, tex) =>
window.MathJax.startup.adaptor.outerHTML(
window.MathJax.tex2svg(tex, {
display: blockMode,
}),
),
});
</script>
</body>
</html>
TIPS: The comment area is only for demo. If you have any questions, please go to Github Discussion to ask.
What do you think?
- 0
- 0
- 0
- 0
- 0
- 0
Powered by Waline v3.3.2