Browse Source

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.
Andreas Kling 5 years ago
parent
commit
4330046aff
1 changed files with 9 additions and 0 deletions
  1. 9 0
      Libraries/LibMarkdown/Text.cpp

+ 9 - 0
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()) {