1.1 --- a/moinformat/parsers/common.py Tue Jul 17 22:38:53 2018 +0200
1.2 +++ b/moinformat/parsers/common.py Tue Jul 17 23:16:52 2018 +0200
1.3 @@ -144,8 +144,15 @@
1.4 match = pattern.search(self.s, self.pos)
1.5 if match:
1.6 start, end = match.span()
1.7 - if self.matching is None or start < self.start:
1.8 +
1.9 + # Where patterns match at the same place, obtain the longest
1.10 + # match.
1.11 +
1.12 + if self.matching is None or start < self.start or \
1.13 + start == self.start and end - start > self.length:
1.14 +
1.15 self.start = start
1.16 + self.length = end - start
1.17 self.matching = pattern_name
1.18 self.match = match
1.19