1
0
mirror of https://github.com/mfontanini/presenterm.git synced 2025-12-28 18:41:29 -06:00

fix: preserve footnote definition location

This commit is contained in:
Matias Fontanini 2025-11-24 16:07:06 -08:00
parent 0cd59d927b
commit 755296fbaf
3 changed files with 12 additions and 8 deletions

4
Cargo.lock generated
View File

@ -209,9 +209,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "comrak"
version = "0.47.0"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13263e1b6ee0147fb4dce60678f8b9634deac47c9b87c3dd5cdb959cc0334d3"
checksum = "48bf2260aceee247c6c5639f5751dc635211895066d782d2a28fb87f2e0d5613"
dependencies = [
"caseless",
"entities",

View File

@ -12,7 +12,7 @@ anyhow = "1"
base64 = "0.22"
bincode = "1.3"
clap = { version = "4.4", features = ["derive", "string", "env"] }
comrak = { version = "0.47.0", default-features = false }
comrak = { version = "0.48.0", default-features = false }
crossterm = { version = "0.29", default-features = false, features = ["events", "windows"] }
directories = "6.0"
hex = "0.4"

View File

@ -36,6 +36,7 @@ impl Default for ParserOptions {
options.extension.wikilinks_title_before_pipe = true;
options.extension.superscript = true;
options.extension.footnotes = true;
options.parse.leave_footnote_definitions = true;
Self(options)
}
}
@ -44,13 +45,13 @@ impl Default for ParserOptions {
///
/// This takes the contents of a markdown file and parses it into a list of [MarkdownElement].
pub struct MarkdownParser<'a> {
arena: &'a Arena<AstNode<'a>>,
arena: &'a Arena<'a>,
options: comrak::Options<'static>,
}
impl<'a> MarkdownParser<'a> {
/// Construct a new markdown parser.
pub fn new(arena: &'a Arena<AstNode<'a>>) -> Self {
pub fn new(arena: &'a Arena<'a>) -> Self {
Self { arena, options: ParserOptions::default().0 }
}
@ -363,13 +364,13 @@ enum StringifyImages {
struct InlinesParser<'a> {
inlines: Vec<Inline>,
pending_text: Vec<Text<RawColor>>,
arena: &'a Arena<AstNode<'a>>,
arena: &'a Arena<'a>,
soft_break: SoftBreak,
stringify_images: StringifyImages,
}
impl<'a> InlinesParser<'a> {
fn new(arena: &'a Arena<AstNode<'a>>, soft_break: SoftBreak, stringify_images: StringifyImages) -> Self {
fn new(arena: &'a Arena<'a>, soft_break: SoftBreak, stringify_images: StringifyImages) -> Self {
Self { inlines: Vec::new(), pending_text: Vec::new(), arena, soft_break, stringify_images }
}
@ -676,6 +677,7 @@ impl Identifier for NodeValue {
NodeValue::Raw(_) => "raw",
NodeValue::Alert(_) => "alert",
NodeValue::Subtext => "subtext",
NodeValue::Highlight => "highlight",
}
}
}
@ -1174,9 +1176,11 @@ mom
this[^1]
[^1]: ref
abc
";
let elements = parse_all(input);
assert_eq!(elements.len(), 2);
assert_eq!(elements.len(), 3);
let MarkdownElement::Paragraph(line) = &elements[0] else { panic!("not a paragraph") };
assert_eq!(line, &[Line(vec![Text::from("this"), Text::new("1", TextStyle::default().superscript())])]);