Skip to content

Commit

Permalink
Migrate to pulldown-cmark 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
russellbanks committed Feb 3, 2024
1 parent 235a77d commit 2bfa85b
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/types/release_notes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use nutype::nutype;
use pulldown_cmark::Event::{Code, End, Start, Text};
use pulldown_cmark::{Event, Options, Parser, Tag};
use pulldown_cmark::{Event, Options, Parser, Tag, TagEnd};
use std::borrow::Cow;
use std::num::NonZeroU32;

Expand All @@ -24,7 +24,18 @@ impl ReleaseNotes {
match event {
Start(tag) => match tag {
Tag::CodeBlock(_info) => buffer.push_str("\n\n"),
Tag::Link(_link_type, _dest, title) | Tag::Image(_link_type, _dest, title) => {
Tag::Link {
link_type: _,
dest_url: _,
title,
id: _,
}
| Tag::Image {
link_type: _,
dest_url: _,
title,
id: _,
} => {
if !title.is_empty() {
buffer.push_str(&title);
}
Expand All @@ -33,13 +44,13 @@ impl ReleaseNotes {
_ => (),
},
End(tag) => match tag {
Tag::Table(_)
| Tag::TableHead
| Tag::TableRow
| Tag::Heading(..)
| Tag::BlockQuote
| Tag::CodeBlock(_) => buffer.push('\n'),
Tag::Item => {
TagEnd::Table
| TagEnd::TableHead
| TagEnd::TableRow
| TagEnd::Heading(..)
| TagEnd::BlockQuote
| TagEnd::CodeBlock => buffer.push('\n'),
TagEnd::Item => {
if &buffer[buffer.len() - 2..] == "- " {
buffer.drain(buffer.len() - 2..);
} else {
Expand Down

0 comments on commit 2bfa85b

Please sign in to comment.