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

#383 in Procedural macros

Download history 3082/week @ 2024-03-14 3924/week @ 2024-03-21 3255/week @ 2024-03-28 4174/week @ 2024-04-04 4172/week @ 2024-04-11 4073/week @ 2024-04-18 3664/week @ 2024-04-25 3754/week @ 2024-05-02 4131/week @ 2024-05-09 4664/week @ 2024-05-16 4628/week @ 2024-05-23 2911/week @ 2024-05-30 3644/week @ 2024-06-06 3363/week @ 2024-06-13 3848/week @ 2024-06-20 2628/week @ 2024-06-27

13,939 downloads per month
Used in 67 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
~34K SLoC