topLevelFenceOpener reports whether a line opens a fenced code block at column 0, returning the fence token ("```" or "~~~") and the declared language (the info string's first word, lowercased).
(line string)
| 162 | // column 0, returning the fence token ("```" or "~~~") and the declared |
| 163 | // language (the info string's first word, lowercased). |
| 164 | func topLevelFenceOpener(line string) (fence, lang string, ok bool) { |
| 165 | switch { |
| 166 | case strings.HasPrefix(line, "```"): |
| 167 | fence = "```" |
| 168 | case strings.HasPrefix(line, "~~~"): |
| 169 | fence = "~~~" |
| 170 | default: |
| 171 | return "", "", false |
| 172 | } |
| 173 | info := strings.TrimSpace(strings.TrimPrefix(line, fence)) |
| 174 | // A line that is only the fence with trailing back-ticks is not an opener |
| 175 | // with a language; info may be empty (plain code block). |
| 176 | if idx := strings.IndexAny(info, " \t"); idx >= 0 { |
| 177 | info = info[:idx] |
| 178 | } |
| 179 | return fence, strings.ToLower(info), true |
| 180 | } |
| 181 | |
| 182 | // isFenceCloser reports whether a line closes a fence opened with the given |
| 183 | // token. A closer is the fence token at column 0 with only optional trailing |
no outgoing calls
no test coverage detected