File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -547,8 +547,16 @@ std::vector<T*> flat_filter(Pattern& pattern) {
547
547
}
548
548
549
549
std::vector<std::string> parse_section (std::string const & name, std::string const & source) {
550
+ // ECMAScript regex only has "?=" for a non-matching lookahead. In order to make sure we always have
551
+ // a newline to anchor our matching, we have to avoid matching the final newline of each grouping.
<
7EAA
/tr>
552
+ // Therefore, our regex is adjusted from the docopt Python one to use ?= to match the newlines before
553
+ // the following lines, rather than after.
550
554
std::regex const re_section_pattern {
551
- " (?:^|\\ n)([^\\ n]*" + name + " [^\\ n]*\\ n?(?:[ \\ t].*?(?:\\ n|$))*)" ,
555
+ " (?:^|\\ n)" // anchored at a linebreak (or start of string)
556
+ " ("
557
+ " [^\\ n]*" + name + " [^\\ n]*(?=\\ n?)" // a line that contains the name
558
+ " (?:\\ n[ \\ t].*?(?=\\ n|$))*" // followed by any number of lines that are indented
559
+ " )" ,
552
560
std::regex::icase
553
561
};
554
562
You can’t perform that action at this time.
0 commit comments