openFenceAfter function
Whether a fence opened in lines is still open after the last line.
The one fence-tracking loop shared by the parser's neighbours (segment splitting, the streaming reveal), so they agree with the parser about where a fence ends.
Fences inside a block quote count: > ```bash opens one, and it
closes with its closing line or when the quote ends.
Implementation
FenceOpen? openFenceAfter(Iterable<String> lines) {
FenceOpen? open;
var depth = 0;
for (final line in lines) {
final current = open;
final lineDepth = quoteDepth(line);
if (current != null && lineDepth >= depth) {
if (isFenceClose(unquoted(line), current)) {
open = null;
}
continue;
}
open = fenceOpen(unquoted(line));
depth = lineDepth;
}
return open;
}