Skip to content

Commit

Permalink
Upgrade pulldown-cmark-to-cmark to 19.0.1 (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdarkhan authored Dec 12, 2024
1 parent 0fdaff1 commit a3bb63f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 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 i18n-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dateparser = "0.2.1"
mdbook.workspace = true
polib.workspace = true
pulldown-cmark = { version = "0.12.2", default-features = false, features = ["html"] }
pulldown-cmark-to-cmark = "18.0.0"
pulldown-cmark-to-cmark = "19.0.1"
regex = "1.11"
semver = "1.0.23"
serde_json.workspace = true
Expand Down
16 changes: 11 additions & 5 deletions i18n-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,17 @@ pub fn reconstruct_markdown<'a>(
// Markdown without the padding to remove the effect of these
// structural elements. Similarly, we don't want extra newlines at
// the start.
let simplified_state = state.map(|state| State {
newlines_before_start: 0,
padding: Vec::new(),
..state
});
let simplified_state = {
// Because State is marked as non_exhaustive, we can't do
// more intuitive mapping/constructing a new instance. Instead,
// doing a clone and in-place mutation.
let mut cloned_state = state.clone();
if let Some(ref mut state) = cloned_state {
state.newlines_before_start = 0;
state.padding = Vec::new();
}
cloned_state
};
cmark_resume_with_options(events, &mut markdown, simplified_state, options).unwrap();
// Even with `newlines_before_start` set to zero, we get a leading
// `\n` for code blocks (since they must start on a new line). We
Expand Down

0 comments on commit a3bb63f

Please sign in to comment.