Katex

TeX math rendering in html

Installation

Import this plugin in your _config.ts file to use it:

import lume from "lume/mod.ts";
import katex from "lume/plugins/katex.ts";

const site = lume();

site.use(katex());

export default site;

See all available options in Deno Doc.

Description

This plugin uses the KaTeX library to render the math typesetting of your HTML documents. You only need to add the language-math extension to any math content that you want to render. In markdown pages, it can be done in code blocks with the math language:

# This is a markdown document

```math
c = \pm\sqrt{a^2 + b^2}
```

Or addign the language-math directly to the html element containing the code:

<p class="language-math">
  c = \pm\sqrt{a^2 + b^2}
</p>

Load styles

To render any HTML generated by katex in the browser, you will need to link the CSS file and use the HTML5 doctype.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.2/dist/katex.css">

See Browser usage in the KaTeX site documentation for more info.