Skip to content

Commit

Permalink
Merge branch 'cmark-12'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 20, 2024
2 parents 7cc274e + 173ae85 commit f1f18d4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2018"
include = ["src/*.rs", "LICENSE-APACHE", "README.md", "CHANGELOG.md"]

[dependencies]
pulldown-cmark = { version = "0.11.0", default-features = false }
pulldown-cmark = { version = "0.12.0", default-features = false }

[dev-dependencies]
indoc = "2.0.5"
Expand Down
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ where
MetadataBlock(MetadataBlockKind::PlusesStyle) => formatter.write_str("+++\n"),
List(_) => Ok(()),
Strikethrough => formatter.write_str("~~"),
DefinitionList => Ok(()),
DefinitionListTitle => formatter.write_char('\n'),
DefinitionListDefinition => formatter.write_str(": "),
}
}
End(ref tag) => match tag {
Expand Down Expand Up @@ -590,7 +593,7 @@ where
}
Ok(())
}
TagEnd::BlockQuote => {
TagEnd::BlockQuote(_) => {
state.padding.pop();

if state.newlines_before_start < options.newlines_after_blockquote {
Expand All @@ -604,6 +607,9 @@ where
Ok(())
}
TagEnd::Strikethrough => formatter.write_str("~~"),
TagEnd::DefinitionList => Ok(()),
TagEnd::DefinitionListTitle => formatter.write_char('\n'),
TagEnd::DefinitionListDefinition => formatter.write_char('\n'),
},
HardBreak => formatter.write_str(" \n").and(padding(formatter, &state.padding)),
SoftBreak => formatter.write_char('\n').and(padding(formatter, &state.padding)),
Expand Down
7 changes: 6 additions & 1 deletion tests/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ mod start {
fn table_cell() {
assert_eq!(s(Start(TableCell)), "|")
}

#[test]
fn definition_list_definition() {
assert_eq!(s(Start(DefinitionListDefinition)), ": ")
}
}

mod end {
Expand All @@ -207,7 +212,7 @@ mod end {
}
#[test]
fn blockquote() {
assert_eq!(s(End(TagEnd::BlockQuote)), "")
assert_eq!(s(End(TagEnd::BlockQuote(None))), "")
}
#[test]
fn codeblock() {
Expand Down
18 changes: 17 additions & 1 deletion tests/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ mod blockquote {
fn it_pops_padding_on_quote_end() {
assert_eq!(
fmtes(
&[Event::End(TagEnd::BlockQuote),],
&[Event::End(TagEnd::BlockQuote(None)),],
State {
padding: vec![" > ".into()],
..Default::default()
Expand Down Expand Up @@ -1503,3 +1503,19 @@ key = value2
}
}
}

mod definition_list {
use super::assert_events_eq;

#[test]
fn round_trip() {
let input = r"First Term
: This is the definition of the first term.
Second Term
: This is one definition of the second term.
: This is another definition of the second term.";

assert_events_eq(input);
}
}

0 comments on commit f1f18d4

Please sign in to comment.