}
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
}
}
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 {