diff --git a/README.md b/README.md index aae4f5c..3ee2bf9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ ___ * italic * bold + italic * inline code +* links # planned features diff --git a/deck_markdown/deck_markdown.go b/deck_markdown/deck_markdown.go index 93dfffc..37aab8c 100644 --- a/deck_markdown/deck_markdown.go +++ b/deck_markdown/deck_markdown.go @@ -35,9 +35,17 @@ func GetMarkDownDescription(text string, configuration utils.Configuration) stri } else { line = fmt.Sprintf("[-:-:-]%s\n", strings.ReplaceAll(line, "```", "")) } + } else if len(checkLink(line)) > 0 { + result := checkLink(line) + for _, r := range result { + rTmp := strings.ReplaceAll(r[1], "[", "") + r[1] = strings.ReplaceAll(rTmp, "]", "") + line = fmt.Sprintf("%s", strings.ReplaceAll(line, r[0], fmt.Sprintf("[#00ffaf]%s [#5f5fff:-:u]%s[-:-:-]", strings.ReplaceAll(r[1], "[", ""), r[2]))) + } } else { line = fmt.Sprintf("%s\n", tview.Escape(line)) } + // bold + italic result := getStringInBetween(line, "\\*\\*\\*", "\\*\\*\\*") if len(result) > 0 { @@ -71,6 +79,7 @@ func GetMarkDownDescription(text string, configuration utils.Configuration) stri } line = fmt.Sprintf("%s", strings.ReplaceAll(line, "`", "")) } + lineContainer = lineContainer + fmt.Sprintf("%s", line) } @@ -86,3 +95,13 @@ func getStringInBetween(str string, start string, end string) (result [][]string return } } + +func checkLink(str string) (result [][]string) { + re := regexp.MustCompile(`(\[[^][]+])\((https?:\/\/[^()]+)\)`) + match := re.FindAllStringSubmatch(str, -1) + if len(match) > 0 { + return match + } else { + return + } +} diff --git a/deck_ui/deck_ui.go b/deck_ui/deck_ui.go index 79af96b..35e220e 100644 --- a/deck_ui/deck_ui.go +++ b/deck_ui/deck_ui.go @@ -7,7 +7,7 @@ import ( "tui-deck/utils" ) -const VERSION = "v0.5.7" +const VERSION = "v0.5.8" var FullFlex = tview.NewFlex() var MainFlex = tview.NewFlex()