1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

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.
This commit is contained in:
Peter Elliott 2022-04-25 17:57:58 -06:00 committed by Andreas Kling
parent e084e1ced6
commit aef5aac772

View file

@ -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());