From 7cae3a058d1df07a9fca3cf15cb046ea6168de98 Mon Sep 17 00:00:00 2001 From: Tuyen Pham <68000455+tuyen-at-work@users.noreply.github.com> Date: Sun, 21 Feb 2021 13:15:50 +0700 Subject: [PATCH 1/3] Support space as seperator between language and additional class in code block This PR try to resolve this issue: https://github.com/rust-lang/mdBook/issues/1384 --- src/utils/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7453f2f280..e401fe4999 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -228,7 +228,14 @@ impl EventQuoteConverter { fn clean_codeblock_headers(event: Event<'_>) -> Event<'_> { match event { Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(ref info))) => { - let info: String = info.chars().filter(|ch| !ch.is_whitespace()).collect(); + let info: String = info + .chars() + .map(|x| match x { + ' ' => ',', + _ => x, + }) + .filter(|ch| !ch.is_whitespace()) + .collect(); Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(CowStr::from(info)))) } From cc74ca2e6e5a888f1b0eda7c4d12ea85c81327ab Mon Sep 17 00:00:00 2001 From: Tuyen Pham <68000455+tuyen-at-work@users.noreply.github.com> Date: Sun, 21 Feb 2021 13:28:16 +0700 Subject: [PATCH 2/3] Update mod.rs --- src/utils/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e401fe4999..68e2c043eb 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -379,7 +379,7 @@ more text with spaces ``` "#; - let expected = r#"
+ let expected = r#"
"#;
assert_eq!(render_markdown(input, false), expected);
assert_eq!(render_markdown(input, true), expected);
From fae0759626daed959f5ed4aacb67a6f5178d3359 Mon Sep 17 00:00:00 2001
From: Eric Huss