Skip to content

Commit

Permalink
Fix pulldown_cmark breaking changes to tag types
Browse files Browse the repository at this point in the history
* Tags and TagEnd are now separate enums since
  <https://redirect.github.com/raphlinus/pulldown-cmark/pull/517>.
* The `Tag::Heading` member has been changed from a tuple variant to a
  struct variant.
  • Loading branch information
the-mikedavis authored and mtoohey31 committed Jun 2, 2024
1 parent aa392f0 commit 7d06a8f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tui::{

use std::sync::Arc;

use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag};
use pulldown_cmark::{CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd};

use helix_core::{
syntax::{self, HighlightEvent, InjectionLanguageMarker, Syntax},
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Markdown {

list_stack.push(list);
}
Event::End(Tag::List(_)) => {
Event::End(TagEnd::List(_)) => {
list_stack.pop();

// whenever top-level list closes, empty line
Expand Down Expand Up @@ -249,15 +249,18 @@ impl Markdown {
Event::End(tag) => {
tags.pop();
match tag {
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) | Tag::Item => {
TagEnd::Heading(_)
| TagEnd::Paragraph
| TagEnd::CodeBlock
| TagEnd::Item => {
push_line(&mut spans, &mut lines);
}
_ => (),
}

// whenever heading, code block or paragraph closes, empty line
match tag {
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) => {
TagEnd::Heading(_) | TagEnd::Paragraph | TagEnd::CodeBlock => {
lines.push(Spans::default());
}
_ => (),
Expand All @@ -279,7 +282,7 @@ impl Markdown {
lines.extend(tui_text.lines.into_iter());
} else {
let style = match tags.last() {
Some(Tag::Heading(level, ..)) => match level {
Some(Tag::Heading { level, .. }) => match level {
HeadingLevel::H1 => heading_styles[0],
HeadingLevel::H2 => heading_styles[1],
HeadingLevel::H3 => heading_styles[2],
Expand Down

0 comments on commit 7d06a8f

Please sign in to comment.