From 4330046aff8097919e4ea97dbb848edcf0f73a42 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 9 May 2020 16:23:05 +0200 Subject: [PATCH] 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. --- Libraries/LibMarkdown/Text.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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()) {