Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 31, 2020
1 parent d64853c commit d68f033
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ where
state.newlines_before_start = options.newlines_after_rule;
}
formatter.write_str("---")
},
}
Code(ref text) => formatter
.write_char('`')
.and_then(|_| formatter.write_str(text))
Expand Down Expand Up @@ -233,9 +233,9 @@ where
// padding or if we're in a list
if consumed_newlines {
formatter.write_str(" > ")
}
else {
formatter.write_char('\n')
} else {
formatter
.write_char('\n')
.and(padding(&mut formatter, &state.padding))
}
}
Expand Down
78 changes: 40 additions & 38 deletions tests/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ fn assert_events_eq(s: &str) {

let after_events = Parser::new_ext(&buf, Options::all());
println!("{}", buf);
assert_eq!(before_events.collect::<Vec<_>>(), after_events.collect::<Vec<_>>());
assert_eq!(
before_events.collect::<Vec<_>>(),
after_events.collect::<Vec<_>>()
);
}

mod lazy_newlines {
Expand Down Expand Up @@ -266,83 +269,77 @@ mod blockquote {

#[test]
fn with_html() {
let s = indoc!("
let s = indoc!(
"
> <table>
> </table>
");
"
);

assert_events_eq(s);

assert_eq!(
fmts(s)
.0,
"\n > \n > <table>\n > </table>\n > ",
)
assert_eq!(fmts(s).0, "\n > \n > <table>\n > </table>\n > ",)
}
#[test]
fn with_inlinehtml() {
assert_eq!(fmts(" > <br>").0, "\n > \n > <br>")
}
#[test]
fn with_codeblock() {
let s = indoc!("
let s = indoc!(
"
> ```a
> t1
> t2
> ```
");
"
);

assert_events_eq(s);

assert_eq!(
fmts(s)
.0,
"\n > \n > ````a\n > t1\n > t2\n > ````",
)
assert_eq!(fmts(s).0, "\n > \n > ````a\n > t1\n > t2\n > ````",)
}
#[test]
fn nested() {
let s = indoc!("
let s = indoc!(
"
> a
>
> > b
>
> c
");
"
);

assert_events_eq(s);

assert_eq!(
fmts(s)
.0,
"\n > \n > a\n > \n > > \n > > b\n > \n > c",
)
assert_eq!(fmts(s).0, "\n > \n > a\n > \n > > \n > > b\n > \n > c",)
}

#[test]
fn initially_nested() {
let s = indoc!("
let s = indoc!(
"
> > foo
> bar
> > baz
");
"
);

assert_events_eq(s);

assert_eq!(
fmts(s)
.0,
"\n > \n > > \n > > foo\n > > bar\n > > baz",
)
assert_eq!(fmts(s).0, "\n > \n > > \n > > foo\n > > bar\n > > baz",)
}

#[test]
fn simple() {
let s = indoc!("
let s = indoc!(
"
> a
> b
> c
");
"
);

assert_events_eq(s);

Expand Down Expand Up @@ -378,11 +375,13 @@ mod blockquote {

#[test]
fn with_blank_line() {
let s = indoc!("
let s = indoc!(
"
> foo
> bar
");
"
);

assert_events_eq(s);

Expand All @@ -400,16 +399,17 @@ mod blockquote {

#[test]
fn with_lazy_continuation() {
let s = indoc!("
let s = indoc!(
"
> foo
baz
> bar
");
"
);

assert_events_eq(s);


assert_eq!(
fmts(s),
(
Expand All @@ -424,11 +424,13 @@ mod blockquote {

#[test]
fn with_lists() {
let s = indoc!("
let s = indoc!(
"
- > * foo
> * baz
- > bar
");
"
);

assert_events_eq(s);

Expand Down

0 comments on commit d68f033

Please sign in to comment.