summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibMarkdown
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2022-04-25 17:57:58 -0600
committerAndreas Kling <kling@serenityos.org>2022-04-26 15:02:26 +0200
commitaef5aac7725cc42a1f0b50e56e0daa9f003fed06 (patch)
tree200c3a42bd7fc1c78624c17aa352e350c205a791 /Userland/Libraries/LibMarkdown
parente084e1ced6029490e319d2cd1c36b3e2aa35b912 (diff)
downloadserenity-aef5aac7725cc42a1f0b50e56e0daa9f003fed06.zip
LibMarkdown: Don't put a newline in empty code blocks
This doesn't actually matter, but I'm trying to match the commonmark test cases where possible.
Diffstat (limited to 'Userland/Libraries/LibMarkdown')
-rw-r--r--Userland/Libraries/LibMarkdown/CodeBlock.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/Userland/Libraries/LibMarkdown/CodeBlock.cpp b/Userland/Libraries/LibMarkdown/CodeBlock.cpp
index a59a15a2aa..7db1f88277 100644
--- a/Userland/Libraries/LibMarkdown/CodeBlock.cpp
+++ b/Userland/Libraries/LibMarkdown/CodeBlock.cpp
@@ -34,7 +34,7 @@ String CodeBlock::render_to_html(bool) const
else
builder.append(escape_html_entities(m_code));
- builder.append("\n</code>");
+ builder.append("</code>");
if (m_style.length() >= 2)
builder.append("</strong>");
@@ -142,7 +142,6 @@ OwnPtr<CodeBlock> CodeBlock::parse_backticks(LineIterator& lines)
++lines;
- bool first = true;
StringBuilder builder;
while (true) {
@@ -157,11 +156,8 @@ OwnPtr<CodeBlock> CodeBlock::parse_backticks(LineIterator& lines)
if (close_fence[0] == fence[0] && close_fence.length() >= fence.length())
break;
}
-
- if (!first)
- builder.append('\n');
builder.append(line);
- first = false;
+ builder.append('\n');
}
return make<CodeBlock>(language, style, builder.build());
@@ -169,7 +165,6 @@ OwnPtr<CodeBlock> CodeBlock::parse_backticks(LineIterator& lines)
OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
{
- bool first = true;
StringBuilder builder;
while (true) {
@@ -184,10 +179,8 @@ OwnPtr<CodeBlock> CodeBlock::parse_indent(LineIterator& lines)
line = line.substring_view(prefix_length.value());
++lines;
- if (!first)
- builder.append('\n');
builder.append(line);
- first = false;
+ builder.append('\n');
}
return make<CodeBlock>("", "", builder.build());