diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12b8f85..8daa482 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: branches: - main + schedule: + # run every morning at 10am Pacific Time + - cron: '0 17 * * *' + name: ci env: @@ -15,7 +19,7 @@ env: RUST_BACKTRACE: 1 # Pin the nightly toolchain to prevent breakage. # This should be occasionally updated. - RUST_NIGHTLY_TOOLCHAIN: nightly-2023-10-06 + RUST_NIGHTLY_TOOLCHAIN: nightly-2024-10-07 jobs: env: diff --git a/Cargo.toml b/Cargo.toml index 1831ff1..e041bc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,10 @@ fnv = { version = "1", default-features = false } glob = "0.3" lazy_static = "1" pathdiff = "0.2" -pulldown-cmark = { version = "0.9", default-features = false } +pulldown-cmark = { version = "0.12", default-features = false } rayon = "1" regex = "1" -reqwest = { version = "0.11", features = ["blocking", "native-tls"] } +reqwest = { version = "0.12", features = ["blocking", "native-tls"] } serde = { version = "1", features = ["derive"] } slug = { version = "0.1" } structopt = "0.3" diff --git a/rust-toolchain b/rust-toolchain index 902c741..dbd4126 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.65.0 +1.81.0 diff --git a/src/specification/markdown.rs b/src/specification/markdown.rs index 4805dd6..4cef717 100644 --- a/src/specification/markdown.rs +++ b/src/specification/markdown.rs @@ -37,7 +37,7 @@ enum Token<'a> { struct Lex<'a> { contents: &'a str, lines: Peekable>, - cmark: Peekable>, + cmark: Peekable>, next_line: Option>, next_token: Option>, } @@ -69,7 +69,7 @@ impl<'a> Iterator for Lex<'a> { type Item = Token<'a>; fn next(&mut self) -> Option { - use pulldown_cmark::{Event::*, HeadingLevel::*, Tag::*}; + use pulldown_cmark::{Event::*, HeadingLevel::*, Tag, TagEnd}; let mut header_buffer = None; let mut text_buffer: Option<(usize, Range)> = None; @@ -92,11 +92,13 @@ impl<'a> Iterator for Lex<'a> { }) { match event { // start buffering the header contents - Start(Heading(_, _, _)) => { - header_buffer = Some((line.line, line.range())); + Start(Tag::Heading { id, .. }) => { + // convert the fragment to a Str + let fragment = id.and_then(|f| line.substr(&f)); + header_buffer = Some((line.line, line.range(), fragment)); } // we're done parsing the header - End(Heading(level, fragment, _classes)) => { + End(TagEnd::Heading(level)) => { // consume any lines captured by the header while self .lines @@ -104,8 +106,12 @@ impl<'a> Iterator for Lex<'a> { .is_some() {} + let fragment = header_buffer + .as_ref() + .and_then(|(_, _, fragment)| *fragment); + // convert the header buffer into a Str - let line = if let Some((line_num, mut buf)) = header_buffer { + let line = if let Some((line_num, mut buf, _)) = header_buffer { let r = line.range(); buf.start = r.start.min(buf.start); buf.end = r.end.max(buf.end); @@ -114,9 +120,6 @@ impl<'a> Iterator for Lex<'a> { line }; - // convert the fragment to a Str - let fragment = fragment.and_then(|f| line.substr(f)); - // convert the text buffer range to a Str let name = if let Some((line_num, mut buf)) = text_buffer { buf.end = line.range().end.max(buf.end); @@ -142,12 +145,12 @@ impl<'a> Iterator for Lex<'a> { }); } // insert a token break before returning the line - Start(Item) => { + Start(Tag::Item) => { self.next_line = Some(line); return Some(Token::Break); } // insert a token break after returning the item line - End(Item) => { + End(TagEnd::Item) => { self.next_token = Some(Token::Break); } // buffer the text if we're parsing a header