Update pulldown-cmark version

This commit is contained in:
Guillaume Gomez 2021-12-25 13:46:27 +01:00
parent f3e5fce6bf
commit ddb0d2396f
5 changed files with 14 additions and 14 deletions

4
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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<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
@ -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<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.

View File

@ -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());

View File

@ -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);