CAD97 / katex-doc

XaaS for KaTeX on docs.rs
12 stars 1 forks source link

XaaS: Use KaTeX on docs.rs!

Thanks to pwnies for bringing this method to where I noticed it. Technically relies on this bug in docs.rs. See the result on docs.rs!

Add the following to your Cargo.toml:

[package.metadata.docs.rs]
rustdoc-args = [
    "--html-in-header",
    ".cargo/registry/src/github.com-1ecc6299db9ec823/katex-doc-0.1.0/katex.html",
]

And use $`inline\ math`$ or

```math
display-style\ math


If it so happens that that path does not always work (because this crate's build isn't in docs.rs cache),
download [katex.html](https://github.com/CAD97/katex-doc/blob/master/katex.html) from this repository,
then put it at the root of your repository, include it in your publish,
and replace the reference to `katex-doc-ver.si.on` with your crate.

For local documentation builds, acquire `katex.html` and use `cargo rustdoc --open -- --html-in-header katex.html`. If
you know how to get `cargo doc` to set flags for rustdoc for just one crate when it's in the dependency graph, so that
KaTeX-enabled docs can render properly when building docs as a dependency, please open an issue so we can document it.