Skip to content

Commit

Permalink
Add markdown-it-footnotes (#5303)
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingo-cant-draw authored Jan 7, 2025
1 parent 0bfbd74 commit 2a89179
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ markdown-it-block-spoiler = "1.0.0"
markdown-it-sub = "1.0.0"
markdown-it-sup = "1.0.0"
markdown-it-ruby = "1.0.0"
markdown-it-footnote = "0.2.0"
moka = { workspace = true, optional = true }

[dev-dependencies]
Expand Down
12 changes: 12 additions & 0 deletions crates/utils/src/utils/markdown/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ static MARKDOWN_PARSER: LazyLock<MarkdownIt> = LazyLock::new(|| {
markdown_it_sub::add(&mut parser);
markdown_it_sup::add(&mut parser);
markdown_it_ruby::add(&mut parser);
markdown_it_footnote::add(&mut parser);
link_rule::add(&mut parser);

parser
Expand Down Expand Up @@ -122,6 +123,17 @@ mod tests {
"ruby text",
"{漢|Kan}{字|ji}",
"<p><ruby>漢<rp>(</rp><rt>Kan</rt><rp>)</rp></ruby><ruby>字<rp>(</rp><rt>ji</rt><rp>)</rp></ruby></p>\n"
),
(
"footnotes",
"Bold claim.[^1]\n\n[^1]: example.com",
"<p>Bold claim.<sup class=\"footnote-ref\"><a href=\"#fn1\" id=\"fnref1\">[1]</a></sup></p>\n\
<hr class=\"footnotes-sep\" />\n\
<section class=\"footnotes\">\n\
<ol class=\"footnotes-list\">\n\
<li id=\"fn1\" class=\"footnote-item\">\n\
<p>example.com <a href=\"#fnref1\" class=\"footnote-backref\">↩︎</a></p>\n\
</li>\n</ol>\n</section>\n"
)
];

Expand Down

0 comments on commit 2a89179

Please sign in to comment.