diff --git a/rustbook-en/packages/mdbook-trpl-note/src/lib.rs b/rustbook-en/packages/mdbook-trpl-note/src/lib.rs index 7a671be1c..774dc82b5 100644 --- a/rustbook-en/packages/mdbook-trpl-note/src/lib.rs +++ b/rustbook-en/packages/mdbook-trpl-note/src/lib.rs @@ -34,7 +34,11 @@ impl Preprocessor for TrplNote { "simple-note-preprocessor" } - fn run(&self, _ctx: &PreprocessorContext, mut book: Book) -> Result { + fn run( + &self, + _ctx: &PreprocessorContext, + mut book: Book, + ) -> Result { book.for_each_mut(|item| { if let BookItem::Chapter(ref mut chapter) = item { chapter.content = rewrite(&chapter.content); @@ -75,7 +79,9 @@ pub fn rewrite(text: &str) -> String { events.extend([ SoftBreak, SoftBreak, - Html(r#"
"#.into()), + Html( + r#"
"#.into(), + ), SoftBreak, SoftBreak, Start(Tag::Paragraph), @@ -89,7 +95,10 @@ pub fn rewrite(text: &str) -> String { } } - (StartingBlockquote(_blockquote_events), heading @ Start(Tag::Heading { .. })) => { + ( + StartingBlockquote(_blockquote_events), + heading @ Start(Tag::Heading { .. }), + ) => { events.extend([ SoftBreak, SoftBreak, @@ -101,14 +110,18 @@ pub fn rewrite(text: &str) -> String { state = InNote; } - (StartingBlockquote(ref mut events), Start(Tag::Paragraph)) => { - events.push(Start(Tag::Paragraph)); + (StartingBlockquote(ref mut events), Start(tag)) => { + events.push(Start(tag)); } (InNote, End(TagEnd::BlockQuote)) => { // As with the start of the block HTML, the closing HTML must be // separated from the Markdown text by two newlines. - events.extend([SoftBreak, SoftBreak, Html("
".into())]); + events.extend([ + SoftBreak, + SoftBreak, + Html("
".into()), + ]); state = Default; } @@ -258,7 +271,8 @@ mod tests { #[test] fn h1_then_blockquote() { - let text = "> # Header\n > And then some note content.\n\n> This is quoted."; + let text = + "> # Header\n > And then some note content.\n\n> This is quoted."; let processed = rewrite(text); assert_eq!( render_markdown(&processed), @@ -268,7 +282,8 @@ mod tests { #[test] fn blockquote_then_h1_note() { - let text = "> This is quoted.\n\n> # Header\n > And then some note content."; + let text = + "> This is quoted.\n\n> # Header\n > And then some note content."; let processed = rewrite(text); assert_eq!( render_markdown(&processed), @@ -276,6 +291,16 @@ mod tests { ); } + #[test] + fn blockquote_with_strong() { + let text = "> **Bold text in a paragraph.**"; + let processed = rewrite(text); + assert_eq!( + render_markdown(&processed), + "
\n

Bold text in a paragraph.

\n
\n" + ); + } + fn render_markdown(text: &str) -> String { let parser = Parser::new(text); let mut buf = String::new(); diff --git a/rustbook-en/src/ch01-03-hello-cargo.md b/rustbook-en/src/ch01-03-hello-cargo.md index 42cd0889c..5750e4f01 100644 --- a/rustbook-en/src/ch01-03-hello-cargo.md +++ b/rustbook-en/src/ch01-03-hello-cargo.md @@ -58,7 +58,7 @@ repository; you can override this behavior by using `cargo new --vcs=git`. Open *Cargo.toml* in your text editor of choice. It should look similar to the code in Listing 1-2. -Filename: Cargo.toml + ```toml [package] @@ -71,8 +71,7 @@ edition = "2021" [dependencies] ``` -Listing 1-2: Contents of *Cargo.toml* generated by `cargo -new` + This file is in the [*TOML*][toml] (*Tom’s Obvious, Minimal Language*) format, which is Cargo’s configuration format.