From a8946eb88857288dec6b9d3db138cc9ff84abe06 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 9 Jun 2021 15:03:27 +0100 Subject: [PATCH] LibMarkdown: Wrap non-inline code blocks in

This fixes #7131

The parser already distinguishes between inline code (handled in
Text.cpp) and triple-tick code blocks, so only
CodeBlock::render_to_html() needed to change. Blank lines within
a code block still cause issues, but that's an HTML issue. (#7121)
---
 Userland/Libraries/LibMarkdown/CodeBlock.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Userland/Libraries/LibMarkdown/CodeBlock.cpp b/Userland/Libraries/LibMarkdown/CodeBlock.cpp
index de2bb0958b..58b5895f91 100644
--- a/Userland/Libraries/LibMarkdown/CodeBlock.cpp
+++ b/Userland/Libraries/LibMarkdown/CodeBlock.cpp
@@ -31,6 +31,8 @@ String CodeBlock::render_to_html() const
     String style_language = this->style_language();
     Text::Style style = this->style();
 
+    builder.append("
");
+
     if (style.strong)
         builder.append("");
     if (style.emph)
@@ -53,7 +55,7 @@ String CodeBlock::render_to_html() const
     if (style.strong)
         builder.append("");
 
-    builder.append('\n');
+    builder.append("
\n"); return builder.build(); }