From ddb0d2396f303bc1314b69a2bd948c03b243ccf6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 25 Dec 2021 13:46:27 +0100 Subject: [PATCH] Update pulldown-cmark version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/book/summary.rs | 16 ++++++++-------- src/renderer/html_handlebars/search.rs | 4 ++-- src/utils/mod.rs | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea59887bee..7d45fac9a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1267,9 +1267,9 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548" dependencies = [ "bitflags", "getopts", diff --git a/Cargo.toml b/Cargo.toml index fc5e1b1693..0d7751cdab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.0" log = "0.4" memchr = "2.0" opener = "0.5" -pulldown-cmark = "0.8.0" +pulldown-cmark = "0.9.0" regex = "1.0.0" serde = "1.0" serde_derive = "1.0" diff --git a/src/book/summary.rs b/src/book/summary.rs index 981e107923..1ade05ecac 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -1,6 +1,6 @@ use crate::errors::*; use memchr::{self, Memchr}; -use pulldown_cmark::{self, Event, Tag}; +use pulldown_cmark::{self, Event, HeadingLevel, Tag}; use std::fmt::{self, Display, Formatter}; use std::iter::FromIterator; use std::ops::{Deref, DerefMut}; @@ -161,7 +161,7 @@ impl From for SummaryItem { /// > match the following regex: "[^<>\n[]]+". struct SummaryParser<'a> { src: &'a str, - stream: pulldown_cmark::OffsetIter<'a>, + stream: pulldown_cmark::OffsetIter<'a, 'a>, offset: usize, /// We can't actually put an event back into the `OffsetIter` stream, so instead we store it @@ -263,7 +263,7 @@ impl<'a> SummaryParser<'a> { loop { match self.next_event() { Some(ev @ Event::Start(Tag::List(..))) - | Some(ev @ Event::Start(Tag::Heading(1))) => { + | Some(ev @ Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => { if is_prefix { // we've finished prefix chapters and are at the start // of the numbered section. @@ -302,10 +302,10 @@ impl<'a> SummaryParser<'a> { break; } - Some(Event::Start(Tag::Heading(1))) => { + Some(Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => { debug!("Found a h1 in the SUMMARY"); - let tags = collect_events!(self.stream, end Tag::Heading(1)); + let tags = collect_events!(self.stream, end Tag::Heading(HeadingLevel::H1, ..)); Some(stringify_events(tags)) } @@ -375,7 +375,7 @@ impl<'a> SummaryParser<'a> { } // The expectation is that pulldown cmark will terminate a paragraph before a new // heading, so we can always count on this to return without skipping headings. - Some(ev @ Event::Start(Tag::Heading(1))) => { + Some(ev @ Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => { // we're starting a new part self.back(ev); break; @@ -527,10 +527,10 @@ impl<'a> SummaryParser<'a> { fn parse_title(&mut self) -> Option { loop { match self.next_event() { - Some(Event::Start(Tag::Heading(1))) => { + Some(Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => { debug!("Found a h1 in the SUMMARY"); - let tags = collect_events!(self.stream, end Tag::Heading(1)); + let tags = collect_events!(self.stream, end Tag::Heading(HeadingLevel::H1, ..)); return Some(stringify_events(tags)); } // Skip a HTML element such as a comment line. diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index 2dc717fb52..39b598008f 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -99,7 +99,7 @@ fn render_item( while let Some(event) = p.next() { match event { - Event::Start(Tag::Heading(i)) if i <= max_section_depth => { + Event::Start(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => { if !heading.is_empty() { // Section finished, the next heading is following now // Write the data to the index, and clear it for the next section @@ -118,7 +118,7 @@ fn render_item( in_heading = true; } - Event::End(Tag::Heading(i)) if i <= max_section_depth => { + Event::End(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => { in_heading = false; section_id = Some(utils::id_from_content(&heading)); breadcrumbs.push(heading.clone()); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3910e3ddfd..44494a8b7b 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -160,7 +160,7 @@ pub fn render_markdown(text: &str, curly_quotes: bool) -> String { render_markdown_with_path(text, curly_quotes, None) } -pub fn new_cmark_parser(text: &str, curly_quotes: bool) -> Parser<'_> { +pub fn new_cmark_parser(text: &str, curly_quotes: bool) -> Parser<'_, '_> { let mut opts = Options::empty(); opts.insert(Options::ENABLE_TABLES); opts.insert(Options::ENABLE_FOOTNOTES);