summaryrefslogtreecommitdiff
path: root/Libraries/LibMarkdown
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-09 16:23:05 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-09 16:23:41 +0200
commit4330046aff8097919e4ea97dbb848edcf0f73a42 (patch)
tree72a709160b80c99b70f223ab9adb60cf4ce64ae5 /Libraries/LibMarkdown
parent00b87167fe28b9acf150ea392a9718c4f180eb42 (diff)
downloadserenity-4330046aff8097919e4ea97dbb848edcf0f73a42.zip
LibMarkdown: Turn absolute links into hyperlinks in terminal output :^)
I'm not completely sure how to handle this nicely for relative links but it would be nice to do that too.
Diffstat (limited to 'Libraries/LibMarkdown')
-rw-r--r--Libraries/LibMarkdown/Text.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibMarkdown/Text.cpp b/Libraries/LibMarkdown/Text.cpp
index 573c2d54ed..dd9b60a4d4 100644
--- a/Libraries/LibMarkdown/Text.cpp
+++ b/Libraries/LibMarkdown/Text.cpp
@@ -149,6 +149,14 @@ String Text::render_for_terminal() const
builder.append('m');
}
+ if (!span.style.href.is_null()) {
+ if (strstr(span.style.href.characters(), "://") != nullptr) {
+ builder.append("\033]8;;");
+ builder.append(span.style.href);
+ builder.append("\033\\");
+ }
+ }
+
builder.append(span.text.characters());
if (needs_styling)
@@ -160,6 +168,7 @@ String Text::render_for_terminal() const
// chance to follow them anyway.
if (strstr(span.style.href.characters(), "://") != nullptr) {
builder.appendf(" <%s>", span.style.href.characters());
+ builder.append("\033]8;;\033\\");
}
}
if (!span.style.img.is_null()) {