Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pulldown-cmark version #1712

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions src/book/summary.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -161,7 +161,7 @@ impl From<Link> 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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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))
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -527,10 +527,10 @@ impl<'a> SummaryParser<'a> {
fn parse_title(&mut self) -> Option<String> {
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.
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/html_handlebars/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down