Add markdown-it-footnotes (#5303)

This commit is contained in:
flamingos-cant 2025-01-07 18:16:30 +00:00 committed by GitHub
parent 0bfbd74e59
commit 2a89179611
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 1 deletions

12
Cargo.lock generated
View file

@ -2837,6 +2837,7 @@ dependencies = [
"lettre",
"markdown-it",
"markdown-it-block-spoiler",
"markdown-it-footnote",
"markdown-it-ruby",
"markdown-it-sub",
"markdown-it-sup",
@ -2901,7 +2902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
"windows-targets 0.48.5",
"windows-targets 0.52.6",
]
[[package]]
@ -3021,6 +3022,15 @@ dependencies = [
"markdown-it",
]
[[package]]
name = "markdown-it-footnote"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6679ab967fbc45b290b25fb477af7556bf6825feec208a970585e6bb9aae3be"
dependencies = [
"markdown-it",
]
[[package]]
name = "markdown-it-ruby"
version = "1.0.0"

View file

@ -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]

View file

@ -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
@ -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"
)
];