From 943e61119c7eb414560b618757a7983bbc94c937 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 31 Jan 2019 09:28:22 +0100 Subject: [PATCH] upgrade hyperlink: can now CONTAIN and be interlaced with other syntaxes --- internal/syntax/hyperlink/hyperlink.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/syntax/hyperlink/hyperlink.go b/internal/syntax/hyperlink/hyperlink.go index 20d4a95..d8815ce 100644 --- a/internal/syntax/hyperlink/hyperlink.go +++ b/internal/syntax/hyperlink/hyperlink.go @@ -10,7 +10,7 @@ type export string var Export = export("hyperlink") func (syn export) Regex() *regexp.Regexp { - return regexp.MustCompile(`(?m)\[([^\[]+)\]\(([^\)]+)\)`) + return regexp.MustCompile(`(?m)([^\033])\[([^(?:\]()]+)\]\(([^\)]+)\)`) } func (syn export) Transform(args ...string) (string, error) { @@ -19,5 +19,8 @@ func (syn export) Transform(args ...string) (string, error) { return "", nil } - return fmt.Sprintf("\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\", args[1], args[0]), nil + linkstart := fmt.Sprintf("\x1b]8;;%s\x1b\\", args[2]) + linkend := fmt.Sprintf("\x1b]8;;\x1b\\") + + return fmt.Sprintf("%s%s%s%s", args[0], linkstart, args[1], linkend), nil }