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

#405 in Procedural macros

Download history 3806/week @ 2024-07-23 3680/week @ 2024-07-30 3262/week @ 2024-08-06 3417/week @ 2024-08-13 3184/week @ 2024-08-20 4371/week @ 2024-08-27 4156/week @ 2024-09-03 2919/week @ 2024-09-10 3341/week @ 2024-09-17 4508/week @ 2024-09-24 3419/week @ 2024-10-01 3620/week @ 2024-10-08 3841/week @ 2024-10-15 3393/week @ 2024-10-22 3468/week @ 2024-10-29 4292/week @ 2024-11-05

15,767 downloads per month
Used in 77 crates (15 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
~37K SLoC