From 32ca1a14ed734f11fc3889b41704605d64d65c5c Mon Sep 17 00:00:00 2001 From: "hui.liu" Date: Mon, 18 May 2020 15:41:56 +0800 Subject: [PATCH] Wrap highlight code blocks with (#1026) * Wrap highlight code blocks with * Fix tests for highlight code block --- components/rendering/src/markdown.rs | 6 ++++-- components/rendering/tests/markdown.rs | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index ba8edfa1..9111e2ce 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -231,7 +231,9 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result"); + Event::Html(html.into()) } Event::End(Tag::CodeBlock(_)) => { if !context.config.highlight_code { @@ -239,7 +241,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result".into()) + Event::Html("".into()) } Event::Start(Tag::Image(link_type, src, title)) => { if is_colocated_asset_link(&src) { diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index 93172be1..e3d48c92 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -39,7 +39,7 @@ fn can_highlight_code_block_no_lang() { let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap(); assert_eq!( res.body, - "
\n$ gutenberg server\n$ ping\n
" + "
\n$ gutenberg server\n$ ping\n
" ); } @@ -53,7 +53,7 @@ fn can_highlight_code_block_with_lang() { let res = render_content("```python\nlist.append(1)\n```", &context).unwrap(); assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); } @@ -68,7 +68,7 @@ fn can_higlight_code_block_with_unknown_lang() { // defaults to plain text assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); }