ソースを参照

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