diff options
author | Benjamin <b.mpickford@outlook.com> | 2019-11-18 06:18:01 +1000 |
---|---|---|
committer | Wim <wim@42.be> | 2019-11-17 21:18:01 +0100 |
commit | 0917dc876613fd71c9726a34bf0138b4f5121be9 (patch) | |
tree | 1eacaadaa4869e8f74ccf65c684c2a80f90787f9 /bridge/helper/helper.go | |
parent | aba86855b5f71c9809d892a7eebc6b69872fcd5b (diff) | |
download | matterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.tar.gz matterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.tar.bz2 matterbridge-msglm-0917dc876613fd71c9726a34bf0138b4f5121be9.zip |
Update markdown parsing library to github.com/gomarkdown/markdown (#944)
Diffstat (limited to 'bridge/helper/helper.go')
-rw-r--r-- | bridge/helper/helper.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index dceb4848..66ba64cb 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -14,8 +14,9 @@ import ( "golang.org/x/image/webp" "github.com/42wim/matterbridge/bridge/config" + "github.com/gomarkdown/markdown" + "github.com/gomarkdown/markdown/parser" "github.com/sirupsen/logrus" - "gitlab.com/golang-commonmark/markdown" ) // DownloadFile downloads the given non-authenticated URL. @@ -176,9 +177,12 @@ func ClipMessage(text string, length int) string { return text } +// ParseMarkdown takes in an input string as markdown and parses it to html func ParseMarkdown(input string) string { - md := markdown.New(markdown.XHTMLOutput(true), markdown.Breaks(true)) - res := md.RenderToString([]byte(input)) + extensions := parser.HardLineBreak + markdownParser := parser.NewWithExtensions(extensions) + parsedMarkdown := markdown.ToHTML([]byte(input), markdownParser, nil) + res := string(parsedMarkdown) res = strings.TrimPrefix(res, "<p>") res = strings.TrimSuffix(res, "</p>\n") return res |