From b339e21526330a45ebb34a96c9d5c4f1f43fa284 Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Mon, 15 Oct 2018 04:10:23 +0800 Subject: [PATCH] Added ability to render slackdown bold. --- gateway/gateway.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gateway/gateway.go b/gateway/gateway.go index c8c67ca0..00844f58 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -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{