I suspect this is a well known problem.
If strings associated with folding are not always opened and closed in a completely nested fashion, then folding gets into trouble. IOW:
startsomething stopsomething startsomethingelse stopsomethingelse
and
startsomething startsomethingelse stopsomethingelse stopsomething
both fold properly, but:
startsomething startsomethingelse stopsomething stopsomethingelse
(which is permissible in ConTeXt and elsewhere) does not.
Is there a solution for pairing specific delimiters such that e.g.
\stopfrontmatter\ is only a "foldingstopmarker" for \startfrontmatter\
?
Perhaps there is some regex or script trickery that can be used here ? I can see how to include multiple matches for a start block, but not whether there is some way to pair them against individual match strings in the stop block.
If not, can we anticipate the bundle rules being extended to enable multiple pairs of foldingmarkers to be included in a syntax ?
Or something else ?
mark.