diff --git a/Cargo.lock b/Cargo.lock index 4041e19..4e3a036 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,9 +1150,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.12.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86ba2052aebccc42cbbb3ed234b8b13ce76f75c3551a303cb2bcffcff12bb14" +checksum = "e9f068eba8e7071c5f9511831b44f32c740d5adf574e990f946ddb53db2f314e" dependencies = [ "bitflags 2.12.1", "getopts", diff --git a/Cargo.toml b/Cargo.toml index b653fb2..289d54a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ unicode-width = "0.2" # `pulldown-cmark` renders inline markdown for terminal display, while # `markdown` provides the mdast/source-structure parser used by selection and # AST views. Keeping both is intentional until one parser can satisfy both jobs. -pulldown-cmark = "0.12" +pulldown-cmark = "0.13" markdown = "1" [dev-dependencies] diff --git a/src/markdown.rs b/src/markdown.rs index 6c31380..ca9ca5c 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -220,6 +220,10 @@ impl MarkdownLineRenderer { MdTag::Emphasis => self.emphasis_depth += 1, MdTag::Strong => self.strong_depth += 1, MdTag::Strikethrough => self.strike_depth += 1, + // These extensions remain disabled in `markdown_options`, so they + // should not normally be emitted. Handle their wrappers explicitly + // to stay compatible with pulldown-cmark 0.13. + MdTag::Superscript | MdTag::Subscript => {} MdTag::Table(_) | MdTag::TableHead | MdTag::TableRow @@ -270,6 +274,7 @@ impl MarkdownLineRenderer { TagEnd::Emphasis => self.emphasis_depth = self.emphasis_depth.saturating_sub(1), TagEnd::Strong => self.strong_depth = self.strong_depth.saturating_sub(1), TagEnd::Strikethrough => self.strike_depth = self.strike_depth.saturating_sub(1), + TagEnd::Superscript | TagEnd::Subscript => {} TagEnd::Paragraph | TagEnd::Item | TagEnd::DefinitionList @@ -412,6 +417,7 @@ impl MarkdownLineRenderer { #[cfg(test)] mod tests { use super::render_markdown_line; + use ratatui::style::Modifier; #[test] fn renders_markdown_headings() { @@ -432,4 +438,21 @@ mod tests { assert_eq!(rendered.plain, line); assert_eq!(rendered.spans.len(), 1); } + + #[test] + fn superscript_stays_literal_and_single_tilde_stays_struck_out() { + let rendered = render_markdown_line("H^2^O and ~CO~"); + assert_eq!(rendered.plain, "H^2^O and CO"); + let carbon_monoxide = rendered + .spans + .iter() + .find(|span| span.content == "CO") + .expect("single-tilde content should be rendered"); + assert!( + carbon_monoxide + .style + .add_modifier + .contains(Modifier::CROSSED_OUT) + ); + } }