mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibMarkdown: Match HTML formatting of Commonmark tests
This patch changes the HTML formatting (where to put newlines, etc...) to better match commonmark's test cases. This has minimal effect of the correctness of our markdown implementation, but makes it easier to test. Changes: - Use <em> instead of <i>. - Newline before end of code block. - <hr /> instead of <hr>. - Newline before first list item. - Newline between lines of a paragraph. - Trim whitespace on lines of paragraphs. Tests passed: 33/652 -> 87/652
This commit is contained in:
parent
8d2c04821f
commit
dee84113ab
Notes:
sideshowbarker
2024-07-18 04:59:27 +09:00
Author: https://github.com/petelliott Commit: https://github.com/SerenityOS/serenity/commit/dee84113abb Pull-request: https://github.com/SerenityOS/serenity/pull/9679 Reviewed-by: https://github.com/ADKaster ✅
@ -36,7 +36,7 @@ String CodeBlock::render_to_html() const
|
||||
if (style.strong)
|
||||
builder.append("<b>");
|
||||
if (style.emph)
|
||||
builder.append("<i>");
|
||||
builder.append("<em>");
|
||||
|
||||
if (style_language.is_empty())
|
||||
builder.append("<code>");
|
||||
@ -48,10 +48,10 @@ String CodeBlock::render_to_html() const
|
||||
else
|
||||
builder.append(escape_html_entities(m_code));
|
||||
|
||||
builder.append("</code>");
|
||||
builder.append("\n</code>");
|
||||
|
||||
if (style.emph)
|
||||
builder.append("</i>");
|
||||
builder.append("</em>");
|
||||
if (style.strong)
|
||||
builder.append("</b>");
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace Markdown {
|
||||
|
||||
String HorizontalRule::render_to_html() const
|
||||
{
|
||||
return "<hr>\n";
|
||||
return "<hr />\n";
|
||||
}
|
||||
|
||||
String HorizontalRule::render_for_terminal(size_t view_width) const
|
||||
|
@ -14,7 +14,7 @@ String List::render_to_html() const
|
||||
StringBuilder builder;
|
||||
|
||||
const char* tag = m_is_ordered ? "ol" : "ul";
|
||||
builder.appendff("<{}>", tag);
|
||||
builder.appendff("<{}>\n", tag);
|
||||
|
||||
for (auto& item : m_items) {
|
||||
builder.append("<li>");
|
||||
|
@ -16,9 +16,9 @@ String Paragraph::render_to_html() const
|
||||
bool first = true;
|
||||
for (auto& line : m_lines) {
|
||||
if (!first)
|
||||
builder.append(' ');
|
||||
builder.append('\n');
|
||||
first = false;
|
||||
builder.append(line.text().render_to_html());
|
||||
builder.append(line.text().render_to_html().trim(" \t"));
|
||||
}
|
||||
builder.append("</p>\n");
|
||||
return builder.build();
|
||||
|
@ -44,7 +44,7 @@ String Text::render_to_html() const
|
||||
bool Style::*flag;
|
||||
};
|
||||
TagAndFlag tags_and_flags[] = {
|
||||
{ "i", &Style::emph },
|
||||
{ "em", &Style::emph },
|
||||
{ "b", &Style::strong },
|
||||
{ "code", &Style::code }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user