mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
6e19ab2bbc
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
49 lines
975 B
C++
49 lines
975 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 {
|
|
|
|
DeprecatedString 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();
|
|
}
|
|
|
|
DeprecatedString 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);
|
|
}
|
|
|
|
}
|