1.1 --- a/moinformat/parsers/common.py Mon Apr 15 15:13:17 2019 +0200
1.2 +++ b/moinformat/parsers/common.py Mon Apr 15 15:13:40 2019 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki parsing functionality.
1.6
1.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -393,22 +393,28 @@
1.13 the 'region' object.
1.14 """
1.15
1.16 - while True:
1.17 - preceding = self.read_until(["directive"], False)
1.18 + try:
1.19 + while True:
1.20 + preceding = self.read_until(["directive"], False)
1.21
1.22 - # With an immediately-appearing directive, handle its details.
1.23 + # With an immediately-appearing directive, handle its details.
1.24
1.25 - if preceding == "":
1.26 - handler = self.handlers.get(self.matching_pattern())
1.27 - if handler:
1.28 - handler(self, region)
1.29 + if preceding == "":
1.30 + handler = self.handlers.get(self.matching_pattern())
1.31 + if handler:
1.32 + handler(self, region)
1.33 + else:
1.34 + break
1.35 +
1.36 + # Otherwise, with no immediate directive (or none at all), stop.
1.37 +
1.38 else:
1.39 break
1.40
1.41 - # Otherwise, with no immediate directive (or none at all), stop.
1.42 + # Handle a premature end of region.
1.43
1.44 - else:
1.45 - break
1.46 + except StopIteration:
1.47 + pass
1.48
1.49 # Parsing utilities.
1.50