Fix pulldown_cmark breaking changes to tag types

* 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.
pull/9551/head
Michael Davis 10 months ago committed by Blaž Hrastnik
parent 630d91168a
commit bbcc89241f

@ -6,7 +6,7 @@ use tui::{
use std::sync::Arc; 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::{ use helix_core::{
syntax::{self, HighlightEvent, InjectionLanguageMarker, Syntax}, syntax::{self, HighlightEvent, InjectionLanguageMarker, Syntax},
@ -209,7 +209,7 @@ impl Markdown {
list_stack.push(list); list_stack.push(list);
} }
Event::End(Tag::List(_)) => { Event::End(TagEnd::List(_)) => {
list_stack.pop(); list_stack.pop();
// whenever top-level list closes, empty line // whenever top-level list closes, empty line
@ -249,7 +249,10 @@ impl Markdown {
Event::End(tag) => { Event::End(tag) => {
tags.pop(); tags.pop();
match tag { match tag {
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) | Tag::Item => { TagEnd::Heading(_)
| TagEnd::Paragraph
| TagEnd::CodeBlock
| TagEnd::Item => {
push_line(&mut spans, &mut lines); push_line(&mut spans, &mut lines);
} }
_ => (), _ => (),
@ -257,7 +260,7 @@ impl Markdown {
// whenever heading, code block or paragraph closes, empty line // whenever heading, code block or paragraph closes, empty line
match tag { match tag {
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::CodeBlock(_) => { TagEnd::Heading(_) | TagEnd::Paragraph | TagEnd::CodeBlock => {
lines.push(Spans::default()); lines.push(Spans::default());
} }
_ => (), _ => (),
@ -279,7 +282,7 @@ impl Markdown {
lines.extend(tui_text.lines.into_iter()); lines.extend(tui_text.lines.into_iter());
} else { } else {
let style = match tags.last() { let style = match tags.last() {
Some(Tag::Heading(level, ..)) => match level { Some(Tag::Heading { level, .. }) => match level {
HeadingLevel::H1 => heading_styles[0], HeadingLevel::H1 => heading_styles[0],
HeadingLevel::H2 => heading_styles[1], HeadingLevel::H2 => heading_styles[1],
HeadingLevel::H3 => heading_styles[2], HeadingLevel::H3 => heading_styles[2],

Loading…
Cancel
Save