Added ability to render slackdown bold.

This commit is contained in:
Patrick Connolly
2018-10-15 04:10:23 +08:00
parent ddda1aad1a
commit b339e21526

View File

@@ -416,6 +416,8 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
allowableTags := []string{
"p",
"i",
"b",
"em",
"strong",
"br",
@@ -440,6 +442,17 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM
return ""
},
})
// Custom override for slackdown
html2md.AddRule("b", &html2md.Rule{
Patterns: []string{"b", "strong"},
Replacement: func(innerHTML string, attrs []string) string {
if len(attrs) > 1 {
// trailing whitespace due to Mandarin issues
return html2md.WrapInlineTag(attrs[1], "*", "* ")
}
return ""
},
})
// Custom override of default code rule:
// This converts multiline code tags to codeblocks
html2md.AddRule("code", &html2md.Rule{