Added ability to handle strikethrough after slackdown parsing. (Updated html2md pkg.)

This commit is contained in:
Patrick Connolly
2018-10-14 23:11:52 +08:00
parent 3253bf2d47
commit 9cdb44d919
3 changed files with 15 additions and 1 deletions

View File

@@ -380,6 +380,16 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
stripped, _ := htmltags.Strip(text, allowableTags, false)
text = stripped.ToString()
html2md.AddRule("del", &html2md.Rule{
Patterns: []string{"del"},
Replacement: func(innerHTML string, attrs []string) string {
if len(attrs) > 1 {
// Extra spaces so that Slack will process, even though Chinese characters don't get spaces
return html2md.WrapInlineTag(attrs[1], " ~", "~ ")
}
return ""
},
})
text := html2md.Convert(text)
// colons: revert temp token