ladybird/Userland/Libraries/LibMarkdown/Paragraph.cpp
Peter Elliott ec9f892899 LibMarkdown: Rewrite Inline text parser to be more forgiving
The previous Text::parse was not able to give up on parsing a textual
element, and just leave it as plain text. Because this is a very
important part of markdown, I fully rewrote the parser to support this
without having to backtrack. Also the parser now some other little
features, such ast delimiter runs and flanking.
2021-09-12 12:17:16 +02:00

29 lines
602 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>
namespace Markdown {
String Paragraph::render_to_html() const
{
StringBuilder builder;
builder.append("<p>");
builder.append(m_text.render_to_html());
builder.append("</p>\n");
return builder.build();
}
String Paragraph::render_for_terminal(size_t) const
{
StringBuilder builder;
builder.append(m_text.render_for_terminal());
builder.append("\n\n");
return builder.build();
}
}