upgrade hyperlink: can now CONTAIN other syntaxes | can be interlaced with other syntaxes (at beginning, or contains [ without a \033 before)

This commit is contained in:
xdrm-brackets 2019-01-31 09:28:57 +01:00
parent 943e61119c
commit 3a25db9d18
1 changed files with 2 additions and 2 deletions

View File

@ -10,12 +10,12 @@ type export string
var Export = export("hyperlink")
func (syn export) Regex() *regexp.Regexp {
return regexp.MustCompile(`(?m)([^\033])\[([^(?:\]()]+)\]\(([^\)]+)\)`)
return regexp.MustCompile(`(?m)(^|[^\x1b])\[([^(?:\]()]+)\]\(([^\)]+)\)`)
}
func (syn export) Transform(args ...string) (string, error) {
// no arg, empty -> ignore
if len(args) < 2 || len(args[0]) < 1 {
if len(args) < 2 || len(args[1]) < 1 {
return "", nil
}