#katex #latex #docs #rustdoc #attributes

horrible-katex-hack

A way of using KaTeX with rustdoc by abusing the doc(html_favicon_url) attribute

4 releases

0.1.3 Apr 4, 2019
0.1.2 Apr 4, 2019
0.1.1 Apr 4, 2019
0.1.0 Apr 4, 2019

#14 in #katex

BSD-2-Clause

4KB

This crate is an example of using $\LaTeX$ math with rustdoc.

This demo abuses the #[doc(html_favicon_url = ..)] attribute to inject a KaTeX script into the generated documentation.

This way, it works both on docs.rs and with cargo doc without extra settings.

Usage

Look at the source of lib.rs of this crate, and copy the doc attribute containing the <link> and <script> tags.

Then, write $`\frac 1 2 + 3`$ for inline math, which renders as $\frac 1 2 + 3$.

Or, write

```math
\int_{-\infty}^\infty f(x)\,dx
```

for display math, which renders as:

\int_{-\infty}^\infty f(x)\,dx

No runtime deps