mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-02 14:19:15 +00:00
LibMarkdown: Render lines to terminal instead of a single string
With this patch, the blocks in a markdown document render a vector of lines. These lines get concatenated in Document::render_to_terminal, so this does not change any external APIs of LibMarkdown. This change makes it possible to indent individual lines in the rendered markdown. So, rendering blockquotes in a similar way to code blocks :^)
This commit is contained in:
parent
7a4b912ece
commit
5cc984d74c
Notes:
sideshowbarker
2024-07-17 02:24:10 +09:00
Author: https://github.com/kuzux
Commit: 5cc984d74c
Pull-request: https://github.com/SerenityOS/serenity/pull/16633
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
20 changed files with 85 additions and 55 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibMarkdown/Paragraph.h>
|
||||
#include <LibMarkdown/Visitor.h>
|
||||
|
@ -27,13 +28,9 @@ DeprecatedString Paragraph::render_to_html(bool tight) const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
DeprecatedString Paragraph::render_for_terminal(size_t) const
|
||||
Vector<DeprecatedString> Paragraph::render_lines_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();
|
||||
return Vector<DeprecatedString> { DeprecatedString::formatted(" {}", m_text.render_for_terminal()), "" };
|
||||
}
|
||||
|
||||
RecursionDecision Paragraph::walk(Visitor& visitor) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue