Skip to content

Commit

Permalink
Merge pull request #1469 from tuyen-at-work/patch-1
Browse files Browse the repository at this point in the history
Support space as seperator between language and additional class in c…
  • Loading branch information
ehuss authored Jul 10, 2021
2 parents 8fb6ac7 + fae0759 commit 27faa54
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
' ' | '\t' => ',',
_ => x,
})
.filter(|ch| !ch.is_whitespace())
.collect();

Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(CowStr::from(info))))
}
Expand Down Expand Up @@ -372,7 +379,7 @@ more text with spaces
```
"#;

let expected = r#"<pre><code class="language-rust,no_run,,,should_panic,,property_3"></code></pre>
let expected = r#"<pre><code class="language-rust,,,,,no_run,,,should_panic,,,,property_3"></code></pre>
"#;
assert_eq!(render_markdown(input, false), expected);
assert_eq!(render_markdown(input, true), expected);
Expand Down

0 comments on commit 27faa54

Please sign in to comment.