From 0917dc876613fd71c9726a34bf0138b4f5121be9 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 18 Nov 2019 06:18:01 +1000 Subject: Update markdown parsing library to github.com/gomarkdown/markdown (#944) --- bridge/helper/helper.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bridge') 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, "

") res = strings.TrimSuffix(res, "

\n") return res -- cgit v1.2.3