feat: syntax highlighting for question codeblocks

This commit is contained in:
httpjamesm
2022-12-28 19:10:14 -05:00
parent 14b11b7f14
commit 96d4f768d9
2 changed files with 19 additions and 0 deletions

View File

@ -64,6 +64,8 @@ func HighlightSyntaxViaContent(content string) (htmlOut string) {
return
}
var preClassRegex = regexp.MustCompile(`(?s)<pre class=".+">`)
func StripBlockTags(content string) (result string) {
// strip all "<code>" tags
content = strings.Replace(content, "<code>", "", -1)
@ -72,6 +74,8 @@ func StripBlockTags(content string) (result string) {
content = strings.Replace(content, "<pre>", "", -1)
content = strings.Replace(content, "</pre>", "", -1)
content = preClassRegex.ReplaceAllString(content, "")
result = content
return