5 releases

0.1.4 Oct 29, 2022
0.1.3 Oct 29, 2022
0.1.2 Apr 6, 2022
0.1.1 Aug 30, 2021
0.1.0 Aug 28, 2021

#449 in Procedural macros

Download history 3083/week @ 2024-02-26 3492/week @ 2024-03-04 2713/week @ 2024-03-11 3704/week @ 2024-03-18 3619/week @ 2024-03-25 3311/week @ 2024-04-01 4099/week @ 2024-04-08 4513/week @ 2024-04-15 3747/week @ 2024-04-22 3892/week @ 2024-04-29 3325/week @ 2024-05-06 4965/week @ 2024-05-13 4696/week @ 2024-05-20 3482/week @ 2024-05-27 3101/week @ 2024-06-03 3503/week @ 2024-06-10

15,537 downloads per month
Used in 65 crates (14 directly)

Apache-2.0

7KB
61 lines

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.

Dependencies

~1.5MB
~35K SLoC