]> git.giacomolli.uk - onechat/blobdiff - markdown.go
Capitalize type names so variables can use them
[onechat] / markdown.go
index 48e9ace0e75970dd8be5f18331edd4b44babb586..1a2f4feb1343723a704a874c2c586e78a0fee8d6 100644 (file)
@@ -169,8 +169,7 @@ func closingFence(lines []string, index int, fence string) int {
        }
 
        for end := index + 1; end < len(lines); end++ {
-               trimmed := strings.TrimSpace(lines[end])
-               if strings.HasPrefix(trimmed, fence) && strings.Trim(trimmed, "`") == "" {
+               if closesFence(lines[end], fence) {
                        return end
                }
        }
@@ -178,6 +177,12 @@ func closingFence(lines []string, index int, fence string) int {
        return -1
 }
 
+// closesFence tells if line closes the code block of fence.
+func closesFence(line, fence string) bool {
+       trimmed := strings.TrimSpace(line)
+       return strings.HasPrefix(trimmed, fence) && strings.Trim(trimmed, "`") == ""
+}
+
 // headingText returns the text of an ATX heading line without its marks, or ""
 // when line is not a heading or has no text.
 func headingText(line string) string {