diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-05 20:12:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-05 22:17:33 +0200 |
commit | 89f5f92b7ebde3866ca229ad37460242b035531f (patch) | |
tree | ce8dd2e2b7cd7f8a9be9a423c2909629668bcf96 /Userland | |
parent | beae2d5caa489f93abe95be603ff741fc524007a (diff) | |
download | serenity-89f5f92b7ebde3866ca229ad37460242b035531f.zip |
LibMarkdown: Convert a bunch of StringBuilder::appendf() => appendff()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibMarkdown/Heading.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibMarkdown/List.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibMarkdown/Paragraph.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibMarkdown/Text.cpp | 14 |
4 files changed, 14 insertions, 18 deletions
diff --git a/Userland/Libraries/LibMarkdown/Heading.cpp b/Userland/Libraries/LibMarkdown/Heading.cpp index 11acf8efb6..8b526debe4 100644 --- a/Userland/Libraries/LibMarkdown/Heading.cpp +++ b/Userland/Libraries/LibMarkdown/Heading.cpp @@ -11,11 +11,7 @@ namespace Markdown { String Heading::render_to_html() const { - StringBuilder builder; - builder.appendf("<h%zu>", m_level); - builder.append(m_text.render_to_html()); - builder.appendf("</h%zu>\n", m_level); - return builder.build(); + return String::formatted("<h{}>{}</h{}>\n", m_level, m_text.render_to_html(), m_level); } String Heading::render_for_terminal(size_t) const diff --git a/Userland/Libraries/LibMarkdown/List.cpp b/Userland/Libraries/LibMarkdown/List.cpp index 04e385fcad..b23baed187 100644 --- a/Userland/Libraries/LibMarkdown/List.cpp +++ b/Userland/Libraries/LibMarkdown/List.cpp @@ -14,7 +14,7 @@ String List::render_to_html() const StringBuilder builder; const char* tag = m_is_ordered ? "ol" : "ul"; - builder.appendf("<%s>", tag); + builder.appendff("<{}>", tag); for (auto& item : m_items) { builder.append("<li>"); @@ -22,7 +22,7 @@ String List::render_to_html() const builder.append("</li>\n"); } - builder.appendf("</%s>\n", tag); + builder.appendff("</{}>\n", tag); return builder.build(); } @@ -35,7 +35,7 @@ String List::render_for_terminal(size_t) const for (auto& item : m_items) { builder.append(" "); if (m_is_ordered) - builder.appendf("%d. ", ++i); + builder.appendff("{}. ", ++i); else builder.append("* "); builder.append(item.render_for_terminal()); diff --git a/Userland/Libraries/LibMarkdown/Paragraph.cpp b/Userland/Libraries/LibMarkdown/Paragraph.cpp index 90d015508b..d252fae464 100644 --- a/Userland/Libraries/LibMarkdown/Paragraph.cpp +++ b/Userland/Libraries/LibMarkdown/Paragraph.cpp @@ -12,7 +12,7 @@ namespace Markdown { String Paragraph::render_to_html() const { StringBuilder builder; - builder.appendf("<p>"); + builder.append("<p>"); bool first = true; for (auto& line : m_lines) { if (!first) @@ -20,7 +20,7 @@ String Paragraph::render_to_html() const first = false; builder.append(line.text().render_to_html()); } - builder.appendf("</p>\n"); + builder.append("</p>\n"); return builder.build(); } @@ -34,7 +34,7 @@ String Paragraph::render_for_terminal(size_t) const first = false; builder.append(line.text().render_for_terminal()); } - builder.appendf("\n\n"); + builder.append("\n\n"); return builder.build(); } diff --git a/Userland/Libraries/LibMarkdown/Text.cpp b/Userland/Libraries/LibMarkdown/Text.cpp index 7d363e8ab7..b399021589 100644 --- a/Userland/Libraries/LibMarkdown/Text.cpp +++ b/Userland/Libraries/LibMarkdown/Text.cpp @@ -72,7 +72,7 @@ String Text::render_to_html() const current_style.img = {}; continue; } - builder.appendf("</%s>", tag.characters()); + builder.appendff("</{}>", tag); if (tag == "a") { current_style.href = {}; continue; @@ -85,16 +85,16 @@ String Text::render_to_html() const } if (current_style.href.is_null() && !span.style.href.is_null()) { open_tags.append("a"); - builder.appendf("<a href=\"%s\">", span.style.href.characters()); + builder.appendff("<a href=\"{}\">", span.style.href); } if (current_style.img.is_null() && !span.style.img.is_null()) { open_tags.append("img"); - builder.appendf("<img src=\"%s\" alt=\"", span.style.img.characters()); + builder.appendff("<img src=\"{}\" alt=\"", span.style.img); } for (auto& tag_and_flag : tags_and_flags) { if (current_style.*tag_and_flag.flag != span.style.*tag_and_flag.flag) { open_tags.append(tag_and_flag.tag); - builder.appendf("<%s>", tag_and_flag.tag.characters()); + builder.appendff("<{}>", tag_and_flag.tag); } } @@ -108,7 +108,7 @@ String Text::render_to_html() const builder.append("\" />"); continue; } - builder.appendf("</%s>", tag.characters()); + builder.appendff("</{}>", tag); } return builder.build(); @@ -153,13 +153,13 @@ String Text::render_for_terminal() const // non-absolute links, because the user has no // chance to follow them anyway. if (strstr(span.style.href.characters(), "://") != nullptr) { - builder.appendf(" <%s>", span.style.href.characters()); + builder.appendff(" <{}>", span.style.href); builder.append("\033]8;;\033\\"); } } if (!span.style.img.is_null()) { if (strstr(span.style.img.characters(), "://") != nullptr) { - builder.appendf(" <%s>", span.style.img.characters()); + builder.appendff(" <{}>", span.style.img); } } } |