@leptosia/docute-katex
v1.0.1
Published
Using [Katex](https://katex.org/) (The fastest math typesetting library for the web) in Docute.
Downloads
6
Readme
@leptosia/docute-katex
Using Katex (The fastest math typesetting library for the web) in Docute.
Usage
First load this plugin via <script>
tag:
<!-- Load the CSS in <head> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
<!-- Load the scripts after docute.js -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@leptosia/docute-katex@1/dist/index.min.js"></script>
This plugin is exposed as window.docuteKatex
:
new Docute({
// ...
plugins: [
docuteKatex()
]
})
Then you can use Vue components to write Tex expressions:
<InlineMath>c = \\pm\\sqrt{a^2 + b^2}</InlineMath>
<!-- or -->
<InlineMath math="c = \\pm\\sqrt{a^2 + b^2}"></InlineMath>
<BlockMath>c = \\pm\\sqrt{a^2 + b^2}</BlockMath>
<!-- or -->
<BlockMath math="c = \\pm\\sqrt{a^2 + b^2}"></BlockMath>
<InlineMath>
wraps the generated HTML with <span>
tag while <BlockMath>
uses <div>
tag.
Optionally you can transform code fences too:
```katex {evaluate: true}
c = \\pm\\sqrt{a^2 + b^2}
```
Then it will be transformed to <BlockMath>
component.
License
MIT © LEPTOSIA