diff options
author | Wim <wim@42.be> | 2019-02-24 15:13:56 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2019-02-24 15:13:56 +0100 |
commit | 96841c70c7d59d1c80f98db7dcdfc03620829758 (patch) | |
tree | df43223b443ab43949c68b265dee518ff3455c47 /bridge/telegram | |
parent | f92735d35d01388ca790c43ef54548ecafae6f92 (diff) | |
download | matterbridge-msglm-96841c70c7d59d1c80f98db7dcdfc03620829758.tar.gz matterbridge-msglm-96841c70c7d59d1c80f98db7dcdfc03620829758.tar.bz2 matterbridge-msglm-96841c70c7d59d1c80f98db7dcdfc03620829758.zip |
Fix regression in HTML handling (telegram). Closes #734
* Revert back to blackfriday v1
* Add testing
Diffstat (limited to 'bridge/telegram')
-rw-r--r-- | bridge/telegram/html.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/bridge/telegram/html.go b/bridge/telegram/html.go index 148f42e6..41326f6f 100644 --- a/bridge/telegram/html.go +++ b/bridge/telegram/html.go @@ -3,7 +3,6 @@ package btelegram import ( "bytes" "html" - "io" "github.com/russross/blackfriday" ) @@ -33,7 +32,7 @@ func (options *customHTML) Header(out *bytes.Buffer, text func() bool, level int options.Paragraph(out, text) } -func (options *customHTML) HRule(out io.ByteWriter) { +func (options *customHTML) HRule(out *bytes.Buffer) { out.WriteByte('\n') //nolint:errcheck } @@ -54,16 +53,13 @@ func (options *customHTML) ListItem(out *bytes.Buffer, text []byte, flags int) { } func makeHTML(input string) string { - extensions := blackfriday.NoIntraEmphasis | - blackfriday.FencedCode | - blackfriday.Autolink | - blackfriday.SpaceHeadings | - blackfriday.HeadingIDs | - blackfriday.BackslashLineBreak | - blackfriday.DefinitionLists - - renderer := &customHTML{blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{ - Flags: blackfriday.UseXHTML | blackfriday.SkipImages, - })} - return string(blackfriday.Run([]byte(input), blackfriday.WithExtensions(extensions), blackfriday.WithRenderer(renderer))) + return string(blackfriday.Markdown([]byte(input), + &customHTML{blackfriday.HtmlRenderer(blackfriday.HTML_USE_XHTML|blackfriday.HTML_SKIP_IMAGES, "", "")}, + blackfriday.EXTENSION_NO_INTRA_EMPHASIS| + blackfriday.EXTENSION_FENCED_CODE| + blackfriday.EXTENSION_AUTOLINK| + blackfriday.EXTENSION_SPACE_HEADERS| + blackfriday.EXTENSION_HEADER_IDS| + blackfriday.EXTENSION_BACKSLASH_LINE_BREAK| + blackfriday.EXTENSION_DEFINITION_LISTS)) } |