summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxSlendiX <gamingxslendix@gmail.com>2022-02-16 23:13:56 +0200
committerAndreas Kling <kling@serenityos.org>2022-02-17 19:54:47 +0100
commit7685d53654ecc4537ed259adeb9363a78bbde229 (patch)
tree1118f78d33bbf970a46dccac507cc9ff51d3b53f
parent5d219ad4f7c342a9c23dfcc81e1d0be709fb3e46 (diff)
downloadserenity-7685d53654ecc4537ed259adeb9363a78bbde229.zip
LibMarkdown: Add terminal color formatting
This patch adds color formatting to markdown viewed in the terminal. This also increases readability.
-rw-r--r--Userland/Libraries/LibMarkdown/Heading.cpp3
-rw-r--r--Userland/Libraries/LibMarkdown/Text.cpp4
2 files changed, 3 insertions, 4 deletions
diff --git a/Userland/Libraries/LibMarkdown/Heading.cpp b/Userland/Libraries/LibMarkdown/Heading.cpp
index 21dff3f039..c4b54aef91 100644
--- a/Userland/Libraries/LibMarkdown/Heading.cpp
+++ b/Userland/Libraries/LibMarkdown/Heading.cpp
@@ -19,15 +19,14 @@ String Heading::render_for_terminal(size_t) const
{
StringBuilder builder;
+ builder.append("\033[0;31;1m\n");
switch (m_level) {
case 1:
case 2:
- builder.append("\n\033[1m");
builder.append(m_text.render_for_terminal().to_uppercase());
builder.append("\033[0m\n");
break;
default:
- builder.append("\n\033[1m");
builder.append(m_text.render_for_terminal());
builder.append("\033[0m\n");
break;
diff --git a/Userland/Libraries/LibMarkdown/Text.cpp b/Userland/Libraries/LibMarkdown/Text.cpp
index faae1d4353..1d91ebf648 100644
--- a/Userland/Libraries/LibMarkdown/Text.cpp
+++ b/Userland/Libraries/LibMarkdown/Text.cpp
@@ -156,7 +156,7 @@ void Text::LinkNode::render_for_terminal(StringBuilder& builder) const
{
bool is_linked = href.contains("://");
if (is_linked) {
- builder.append("\e]8;;");
+ builder.append("\033[0;34m\e]8;;");
builder.append(href);
builder.append("\e\\");
}
@@ -165,7 +165,7 @@ void Text::LinkNode::render_for_terminal(StringBuilder& builder) const
if (is_linked) {
builder.appendff(" <{}>", href);
- builder.append("\033]8;;\033\\");
+ builder.append("\033]8;;\033\\\033[0m");
}
}