Skip to content

Commit

Permalink
build(deps): bump pulldown-cmark from 0.9.6 to 0.10.3
Browse files Browse the repository at this point in the history
Bumps [pulldown-cmark](https://github.com/raphlinus/pulldown-cmark) from 0.9.6 to 0.10.3.
- [Release notes](https://github.com/raphlinus/pulldown-cmark/releases)
- [Commits](pulldown-cmark/pulldown-cmark@v0.9.6...v0.10.3)

---
updated-dependencies:
- dependency-name: pulldown-cmark
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
  • Loading branch information
dependabot[bot] authored and matoous committed Apr 24, 2024
1 parent 494d93b commit 86e0010
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
11 changes: 9 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 mwp-content/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ categories.workspace = true
repository.workspace = true

[dependencies]
pulldown-cmark = "0.9.6"
pulldown-cmark = "0.10.3"
url = "2.5.0"
walkdir = "2.5.0"
50 changes: 26 additions & 24 deletions mwp-content/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
path::{Path, PathBuf},
};

use pulldown_cmark::{html, Event, HeadingLevel, Options, Parser, Tag};
use pulldown_cmark::{html, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
use url::Url;
use walkdir::WalkDir;

Expand Down Expand Up @@ -78,16 +78,22 @@ impl Page {
let parser = Parser::new_ext(&content, options).filter_map(|event| match event.clone() {
Event::Text(text) => {
if page_title.is_empty()
&& open_tags
.last()
.is_some_and(|tag| matches!(tag, Tag::Heading(HeadingLevel::H1, _, _)))
&& open_tags.last().is_some_and(|tag| {
matches!(
tag,
Tag::Heading {
level: HeadingLevel::H1,
..
}
)
})
{
page_title = text.to_string();
}

if open_tags
.last()
.is_some_and(|tag| matches!(tag, Tag::Link(_, _, _)))
.is_some_and(|tag| matches!(tag, Tag::Link { .. }))
{
link_title = text.to_string();
}
Expand All @@ -98,27 +104,23 @@ impl Page {
open_tags.push(tag);
Some(event)
}
Event::End(tag) => {
match tag.clone() {
Tag::Link(_, url, _) => {
if let Ok(url) = Url::parse(&url) {
links.push(Link {
title: link_title.clone(),
url,
starred: open_tags.iter().any(|tag| matches!(tag, Tag::Strong)),
tags: tags.clone(),
});
link_title.clear();
}
}
Tag::Heading(_, _, _) | Tag::Paragraph | Tag::Item => {
writeln!(&mut text_output).expect("write text output");
Event::End(TagEnd::Heading(..) | TagEnd::Paragraph | TagEnd::Item) => {
writeln!(&mut text_output).expect("write text output");
open_tags.pop();
Some(event)
}
Event::End(TagEnd::Link) => {
if let Some(Tag::Link { dest_url, .. }) = open_tags.pop() {
if let Ok(url) = Url::parse(&dest_url) {
links.push(Link {
title: link_title.clone(),
url,
starred: open_tags.iter().any(|tag| matches!(tag, Tag::Strong)),
tags: tags.clone(),
});
link_title.clear();
}
_ => {}
}

open_tags.pop();

Some(event)
}
event => Some(event),
Expand Down
2 changes: 1 addition & 1 deletion mwp-scraper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository.workspace = true
html-escape = "0.2.13"
lazy_static = "1.4.0"
lol_html = "1.2.1"
pulldown-cmark = "0.9.6"
pulldown-cmark = "0.10.3"
regex = "1.10.4"
reqwest = "0.12.4"
serde = "1.0.198"
Expand Down

0 comments on commit 86e0010

Please sign in to comment.