Skip to content

Commit 68a5c09

Browse files
authored
Merge pull request #1712 from GuillaumeGomez/pulldown-cmark
Update pulldown-cmark version
2 parents 97b6a35 + ddb0d23 commit 68a5c09

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lazy_static = "1.0"
2525
log = "0.4"
2626
memchr = "2.0"
2727
opener = "0.5"
28-
pulldown-cmark = "0.8.0"
28+
pulldown-cmark = "0.9.0"
2929
regex = "1.0.0"
3030
serde = "1.0"
3131
serde_derive = "1.0"

src/book/summary.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::errors::*;
22
use memchr::{self, Memchr};
3-
use pulldown_cmark::{self, Event, Tag};
3+
use pulldown_cmark::{self, Event, HeadingLevel, Tag};
44
use std::fmt::{self, Display, Formatter};
55
use std::iter::FromIterator;
66
use std::ops::{Deref, DerefMut};
@@ -161,7 +161,7 @@ impl From<Link> for SummaryItem {
161161
/// > match the following regex: "[^<>\n[]]+".
162162
struct SummaryParser<'a> {
163163
src: &'a str,
164-
stream: pulldown_cmark::OffsetIter<'a>,
164+
stream: pulldown_cmark::OffsetIter<'a, 'a>,
165165
offset: usize,
166166

167167
/// 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> {
263263
loop {
264264
match self.next_event() {
265265
Some(ev @ Event::Start(Tag::List(..)))
266-
| Some(ev @ Event::Start(Tag::Heading(1))) => {
266+
| Some(ev @ Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => {
267267
if is_prefix {
268268
// we've finished prefix chapters and are at the start
269269
// of the numbered section.
@@ -302,10 +302,10 @@ impl<'a> SummaryParser<'a> {
302302
break;
303303
}
304304

305-
Some(Event::Start(Tag::Heading(1))) => {
305+
Some(Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => {
306306
debug!("Found a h1 in the SUMMARY");
307307

308-
let tags = collect_events!(self.stream, end Tag::Heading(1));
308+
let tags = collect_events!(self.stream, end Tag::Heading(HeadingLevel::H1, ..));
309309
Some(stringify_events(tags))
310310
}
311311

@@ -375,7 +375,7 @@ impl<'a> SummaryParser<'a> {
375375
}
376376
// The expectation is that pulldown cmark will terminate a paragraph before a new
377377
// heading, so we can always count on this to return without skipping headings.
378-
Some(ev @ Event::Start(Tag::Heading(1))) => {
378+
Some(ev @ Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => {
379379
// we're starting a new part
380380
self.back(ev);
381381
break;
@@ -527,10 +527,10 @@ impl<'a> SummaryParser<'a> {
527527
fn parse_title(&mut self) -> Option<String> {
528528
loop {
529529
match self.next_event() {
530-
Some(Event::Start(Tag::Heading(1))) => {
530+
Some(Event::Start(Tag::Heading(HeadingLevel::H1, ..))) => {
531531
debug!("Found a h1 in the SUMMARY");
532532

533-
let tags = collect_events!(self.stream, end Tag::Heading(1));
533+
let tags = collect_events!(self.stream, end Tag::Heading(HeadingLevel::H1, ..));
534534
return Some(stringify_events(tags));
535535
}
536536
// Skip a HTML element such as a comment line.

src/renderer/html_handlebars/search.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn render_item(
9999

100100
while let Some(event) = p.next() {
101101
match event {
102-
Event::Start(Tag::Heading(i)) if i <= max_section_depth => {
102+
Event::Start(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => {
103103
if !heading.is_empty() {
104104
// Section finished, the next heading is following now
105105
// Write the data to the index, and clear it for the next section
@@ -118,7 +118,7 @@ fn render_item(
118118

119119
in_heading = true;
120120
}
121-
Event::End(Tag::Heading(i)) if i <= max_section_depth => {
121+
Event::End(Tag::Heading(i, ..)) if i as u32 <= max_section_depth => {
122122
in_heading = false;
123123
section_id = Some(utils::id_from_content(&heading));
124124
breadcrumbs.push(heading.clone());

src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn render_markdown(text: &str, curly_quotes: bool) -> String {
160160
render_markdown_with_path(text, curly_quotes, None)
161161
}
162162

163-
pub fn new_cmark_parser(text: &str, curly_quotes: bool) -> Parser<'_> {
163+
pub fn new_cmark_parser(text: &str, curly_quotes: bool) -> Parser<'_, '_> {
164164
let mut opts = Options::empty();
165165
opts.insert(Options::ENABLE_TABLES);
166166
opts.insert(Options::ENABLE_FOOTNOTES);

0 commit comments

Comments
 (0)