diff --git a/Cargo.lock b/Cargo.lock index 482409a..3ddbc08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1425,6 +1425,16 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "github-slugger" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "721820f4eab1c427d482e144b63288754d9872fb7f0d72d73ab101008ef43147" +dependencies = [ + "once_cell", + "regex", +] + [[package]] name = "gloo-net" version = "0.6.0" @@ -1736,6 +1746,7 @@ dependencies = [ "log", "markdown-it", "markdown-it-block-spoiler", + "markdown-it-heading-anchors", "once_cell", "pretty_assertions", "rand", @@ -2304,6 +2315,16 @@ dependencies = [ "markdown-it", ] +[[package]] +name = "markdown-it-heading-anchors" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8c71a46fc41bf2fdac133c188c1477562b7bcd1be3981e84fc81cfc2e515fe" +dependencies = [ + "github-slugger", + "markdown-it", +] + [[package]] name = "matchit" version = "0.7.3" diff --git a/Cargo.toml b/Cargo.toml index bf0ee20..42d3ab2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,6 +82,7 @@ tower-layer = "0.3.3" katex = { version = "0.4", default-features = false } include_dir = "0.7.4" markdown-it-block-spoiler = "1.0.0" +markdown-it-heading-anchors = "0.3.0" [dev-dependencies] pretty_assertions = "1.4.1" diff --git a/src/frontend/markdown.rs b/src/frontend/markdown.rs index 79e09aa..5c9e692 100644 --- a/src/frontend/markdown.rs +++ b/src/frontend/markdown.rs @@ -29,6 +29,7 @@ pub fn render_markdown(text: &str) -> String { fn markdown_parser() -> MarkdownIt { let mut parser = MarkdownIt::new(); markdown_it::plugins::cmark::add(&mut parser); + markdown_it_heading_anchors::add(&mut parser); markdown_it::plugins::extra::strikethrough::add(&mut parser); markdown_it::plugins::extra::tables::add(&mut parser); markdown_it::plugins::extra::typographer::add(&mut parser);