瀏覽代碼

LibMarkdown: Wrap non-inline code blocks in <pre>

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)
Sam Atkins 4 年之前
父節點
當前提交
a8946eb888
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibMarkdown/CodeBlock.cpp

+ 3 - 1
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("<pre>");
+
     if (style.strong)
         builder.append("<b>");
     if (style.emph)
@@ -53,7 +55,7 @@ String CodeBlock::render_to_html() const
     if (style.strong)
         builder.append("</b>");
 
-    builder.append('\n');
+    builder.append("</pre>\n");
 
     return builder.build();
 }