From 585d1556c18abc8b259819847d05b2b088bee806 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 2 Feb 2020 18:35:43 +0100 Subject: Disable smartypants in markdown parser. Fixes #989, #983 (#993) --- bridge/helper/helper.go | 6 +++++- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/gomarkdown/markdown/html/doc.go | 2 +- vendor/github.com/gomarkdown/markdown/parser/inline.go | 2 +- vendor/modules.txt | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bridge/helper/helper.go b/bridge/helper/helper.go index 66ba64cb..8d75a8ad 100644 --- a/bridge/helper/helper.go +++ b/bridge/helper/helper.go @@ -15,6 +15,7 @@ import ( "github.com/42wim/matterbridge/bridge/config" "github.com/gomarkdown/markdown" + "github.com/gomarkdown/markdown/html" "github.com/gomarkdown/markdown/parser" "github.com/sirupsen/logrus" ) @@ -181,7 +182,10 @@ func ClipMessage(text string, length int) string { func ParseMarkdown(input string) string { extensions := parser.HardLineBreak markdownParser := parser.NewWithExtensions(extensions) - parsedMarkdown := markdown.ToHTML([]byte(input), markdownParser, nil) + renderer := html.NewRenderer(html.RendererOptions{ + Flags: 0, + }) + parsedMarkdown := markdown.ToHTML([]byte(input), markdownParser, renderer) res := string(parsedMarkdown) res = strings.TrimPrefix(res, "

") res = strings.TrimSuffix(res, "

\n") diff --git a/go.mod b/go.mod index d47fa936..6f6cddcb 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/dfordsoft/golib v0.0.0-20180902042739-76ee6ab99bec github.com/fsnotify/fsnotify v1.4.7 github.com/go-telegram-bot-api/telegram-bot-api v4.6.5-0.20181225215658-ec221ba9ea45+incompatible - github.com/gomarkdown/markdown v0.0.0-20200105192015-0948ad373b2c + github.com/gomarkdown/markdown v0.0.0-20200127000047-1813ea067497 github.com/google/gops v0.3.6 github.com/gopackage/ddp v0.0.0-20170117053602-652027933df4 // indirect github.com/gorilla/schema v1.1.0 diff --git a/go.sum b/go.sum index c356ee32..8d15de15 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/gomarkdown/markdown v0.0.0-20200105192015-0948ad373b2c h1:YQi5cVUn3bbQSS7fadb1G9LLp+sqYk5bQEw+VYes7MQ= -github.com/gomarkdown/markdown v0.0.0-20200105192015-0948ad373b2c/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= +github.com/gomarkdown/markdown v0.0.0-20200127000047-1813ea067497 h1:wJkj+x9gPYlDyM34C6r3SXPs270coWeh85wu1CsusDo= +github.com/gomarkdown/markdown v0.0.0-20200127000047-1813ea067497/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/gops v0.3.6 h1:6akvbMlpZrEYOuoebn2kR+ZJekbZqJ28fJXTs84+8to= diff --git a/vendor/github.com/gomarkdown/markdown/html/doc.go b/vendor/github.com/gomarkdown/markdown/html/doc.go index f837c63d..b8d498d6 100644 --- a/vendor/github.com/gomarkdown/markdown/html/doc.go +++ b/vendor/github.com/gomarkdown/markdown/html/doc.go @@ -8,7 +8,7 @@ A renderer can be configured with multiple options: import "github.com/gomarkdown/markdown/html" flags := html.CommonFlags | html.CompletePage | html.HrefTargetBlank - opts := html.RenderOptions{ + opts := html.RendererOptions{ TItle: "A custom title", Flags: flags, } diff --git a/vendor/github.com/gomarkdown/markdown/parser/inline.go b/vendor/github.com/gomarkdown/markdown/parser/inline.go index 23849f3a..2a8ac77c 100644 --- a/vendor/github.com/gomarkdown/markdown/parser/inline.go +++ b/vendor/github.com/gomarkdown/markdown/parser/inline.go @@ -689,7 +689,7 @@ func leftAngle(p *Parser, data []byte, offset int) (int, ast.Node) { } // '\\' backslash escape -var escapeChars = []byte("\\`*_{}[]()#+-.!:|&<>~") +var escapeChars = []byte("\\`*_{}[]()#+-.!:|&<>~^") func escape(p *Parser, data []byte, offset int) (int, ast.Node) { data = data[offset:] diff --git a/vendor/modules.txt b/vendor/modules.txt index 32b59b59..0fba40d5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -44,7 +44,7 @@ github.com/go-telegram-bot-api/telegram-bot-api # github.com/golang/protobuf v1.3.1 github.com/golang/protobuf/proto github.com/golang/protobuf/protoc-gen-go/descriptor -# github.com/gomarkdown/markdown v0.0.0-20200105192015-0948ad373b2c +# github.com/gomarkdown/markdown v0.0.0-20200127000047-1813ea067497 github.com/gomarkdown/markdown github.com/gomarkdown/markdown/ast github.com/gomarkdown/markdown/html -- cgit v1.2.3