ladybird/Userland/Libraries/LibMarkdown/Paragraph.cpp
sin-ack 3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00

49 lines
955 B
C++

/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/StringBuilder.h>
#include <LibMarkdown/Paragraph.h>
#include <LibMarkdown/Visitor.h>
namespace Markdown {
String Paragraph::render_to_html(bool tight) const
{
StringBuilder builder;
if (!tight)
builder.append("<p>"sv);
builder.append(m_text.render_to_html());
if (!tight)
builder.append("</p>"sv);
builder.append('\n');
return builder.build();
}
String Paragraph::render_for_terminal(size_t) const
{
StringBuilder builder;
builder.append(" "sv);
builder.append(m_text.render_for_terminal());
builder.append("\n\n"sv);
return builder.build();
}
RecursionDecision Paragraph::walk(Visitor& visitor) const
{
RecursionDecision rd = visitor.visit(*this);
if (rd != RecursionDecision::Recurse)
return rd;
return m_text.walk(visitor);
}
}