mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibMarkdown: Add additional spacing for terminal rendering
This patch adds spacing to give a sense of structure to markdown documents viewed in the terminal. This also makes the content easier to read.
This commit is contained in:
parent
19b7a5fe0d
commit
5d219ad4f7
4 changed files with 10 additions and 5 deletions
|
@ -49,8 +49,11 @@ String CodeBlock::render_for_terminal(size_t) const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
builder.append(m_code);
|
for (auto line : m_code.split('\n')) {
|
||||||
builder.append("\n\n");
|
builder.append(" ");
|
||||||
|
builder.append(line);
|
||||||
|
builder.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,11 @@ String List::render_for_terminal(size_t) const
|
||||||
for (auto& item : m_items) {
|
for (auto& item : m_items) {
|
||||||
builder.append(" ");
|
builder.append(" ");
|
||||||
if (m_is_ordered)
|
if (m_is_ordered)
|
||||||
builder.appendff("{}. ", ++i);
|
builder.appendff("{}.", ++i);
|
||||||
else
|
else
|
||||||
builder.append("* ");
|
builder.append("*");
|
||||||
builder.append(item->render_for_terminal());
|
builder.append(item->render_for_terminal());
|
||||||
}
|
}
|
||||||
builder.append("\n");
|
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ String Paragraph::render_to_html(bool tight) const
|
||||||
String Paragraph::render_for_terminal(size_t) const
|
String Paragraph::render_for_terminal(size_t) const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
builder.append(" ");
|
||||||
builder.append(m_text.render_for_terminal());
|
builder.append(m_text.render_for_terminal());
|
||||||
builder.append("\n\n");
|
builder.append("\n\n");
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|
|
@ -63,6 +63,8 @@ String Table::render_for_terminal(size_t view_width) const
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.append("\n");
|
||||||
|
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue