katexit

Crates.iokatexit
lib.rskatexit
version0.1.4
sourcesrc
created_at2021-08-28 07:40:05.59558
updated_at2022-10-29 12:35:53.758248
descriptionInsert KaTeX autorender script into rustdoc
homepage
repositoryhttps://github.com/termoshtt/katexit
max_upload_size
id443360
size6,426
Toshiki Teramura (termoshtt)

documentation

https://docs.rs/katexit

README

Crate docs.rs

Insert KaTeX autorender script into rustdoc

Usage

#[cfg_attr(doc, katexit::katexit)]
/// We can write $\LaTeX$ expressions
///
/// Display style
/// -------------
///
/// $$
/// c = \\pm\\sqrt{a^2 + b^2}
/// $$
pub fn my_func() {}

See rendered result on docs.rs.

How it works

#[katexit] proc-macro inserts KaTeX autorender script as #[doc = "{script}"]. Since the markdown to HTML translator of rustdoc do not touch HTML partitions embedded in markdown, they will be passed as it is to the browser. The autorender script starts rendering the math expression enclosed by $ written in the document section when you open the page generated by rustdoc, i.e. this does not work offline.

Links

Commit count: 43

cargo fmt