diff --git a/plugin_bbcode.go b/plugin_bbcode.go
index acc12638..36a698a1 100644
--- a/plugin_bbcode.go
+++ b/plugin_bbcode.go
@@ -18,7 +18,8 @@ var bbcodeMissingTag []byte
var bbcodeBold *regexp.Regexp
var bbcodeItalic *regexp.Regexp
var bbcodeUnderline *regexp.Regexp
-var bbcodeStrikethrough *regexp.Regexp
+var bbcodeStrike *regexp.Regexp
+var bbcodeH1 *regexp.Regexp
var bbcodeURL *regexp.Regexp
var bbcodeURLLabel *regexp.Regexp
var bbcodeQuotes *regexp.Regexp
@@ -38,7 +39,8 @@ func initBbcode(plugin *common.Plugin) error {
bbcodeBold = regexp.MustCompile(`(?s)\[b\](.*)\[/b\]`)
bbcodeItalic = regexp.MustCompile(`(?s)\[i\](.*)\[/i\]`)
bbcodeUnderline = regexp.MustCompile(`(?s)\[u\](.*)\[/u\]`)
- bbcodeStrikethrough = regexp.MustCompile(`(?s)\[s\](.*)\[/s\]`)
+ bbcodeStrike = regexp.MustCompile(`(?s)\[s\](.*)\[/s\]`)
+ bbcodeH1 = regexp.MustCompile(`(?s)\[h1\](.*)\[/h1\]`)
urlpattern := `(http|https|ftp|mailto*)(:??)\/\/([\.a-zA-Z\/]+)`
bbcodeURL = regexp.MustCompile(`\[url\]` + urlpattern + `\[/url\]`)
bbcodeURLLabel = regexp.MustCompile(`(?s)\[url=` + urlpattern + `\](.*)\[/url\]`)
@@ -57,10 +59,11 @@ func bbcodeRegexParse(msg string) string {
msg = bbcodeBold.ReplaceAllString(msg, "$1")
msg = bbcodeItalic.ReplaceAllString(msg, "$1")
msg = bbcodeUnderline.ReplaceAllString(msg, "$1")
- msg = bbcodeStrikethrough.ReplaceAllString(msg, "$1")
+ msg = bbcodeStrike.ReplaceAllString(msg, "$1")
msg = bbcodeURL.ReplaceAllString(msg, "$1$2//$3")
msg = bbcodeURLLabel.ReplaceAllString(msg, "$4")
msg = bbcodeQuotes.ReplaceAllString(msg, "$1
")
+ msg = bbcodeH1.ReplaceAllString(msg, "$1
")
//msg = bbcodeCode.ReplaceAllString(msg,"$1")
return msg
}
@@ -321,10 +324,12 @@ func bbcodeFullParse(msg string) string {
msg = string(msgbytes[0 : len(msgbytes)-10])
}
+ // TODO: Optimise these
//msg = bbcode_url.ReplaceAllString(msg,"$1$2//$3")
msg = bbcodeURLLabel.ReplaceAllString(msg, "$4")
msg = bbcodeQuotes.ReplaceAllString(msg, "$1
")
msg = bbcodeCode.ReplaceAllString(msg, "$1")
+ msg = bbcodeH1.ReplaceAllString(msg, "$1
")
} else {
msg = string(msgbytes[0 : len(msgbytes)-10])
}
diff --git a/plugin_test.go b/plugin_test.go
index 44aef066..59f51e98 100644
--- a/plugin_test.go
+++ b/plugin_test.go
@@ -48,6 +48,8 @@ func TestBBCodeRender(t *testing.T) {
msgList.Add("[i]hi[/i]", "hi")
msgList.Add("[s]hi[/s]", "hi")
msgList.Add("[c]hi[/c]", "[c]hi[/c]")
+ msgList.Add("[h1]hi", "[h1]hi")
+ msgList.Add("[h1]hi[/h1]", "hi
")
if !testing.Short() {
//msgList.Add("[b]hi[/i]", "[b]hi[/i]")
//msgList.Add("[/b]hi[b]", "[/b]hi[b]")
@@ -250,6 +252,8 @@ func TestMarkdownRender(t *testing.T) {
msgList2.Add("#", "#")
msgList2.Add("#h", "h
")
msgList2.Add("#hi", "hi
")
+ msgList2.Add("# hi", "hi
")
+ msgList2.Add("# hi", "hi
")
msgList.Add("\n#", "\n#")
msgList.Add("\n#h", "\nh
")
msgList.Add("\n#hi", "\nhi
")