1.1 --- a/moinformat/parsers/table.py Thu Jul 26 20:42:37 2018 +0200
1.2 +++ b/moinformat/parsers/table.py Sat Jul 28 12:49:22 2018 +0200
1.3 @@ -37,12 +37,13 @@
1.4
1.5 def parse_region_content(self, items, region):
1.6
1.7 - "Parse the data provided by 'items' to populate the given 'region'."
1.8 + """
1.9 + Parse the data provided by 'items' to populate the given 'region'. For
1.10 + table regions, normal region handling is wrapped by management of the
1.11 + table structure.
1.12 + """
1.13
1.14 self.set_region(items, region)
1.15 - self.parse_table_region()
1.16 -
1.17 - def parse_table_region(self):
1.18
1.19 # Start to populate table rows.
1.20
1.21 @@ -52,7 +53,7 @@
1.22 self.append_node(self.region, table)
1.23
1.24 while True:
1.25 - self.parse_region_details(cell, self.table_region_pattern_names)
1.26 + self.parse_region_details(cell, self.region_pattern_names)
1.27
1.28 # Detect the end of the table.
1.29
1.30 @@ -80,18 +81,7 @@
1.31 feature = self.match_group("feature")
1.32 cell.append(Continuation(feature))
1.33
1.34 - def parse_table_end(self, cell):
1.35
1.36 - "Handle the end of a region within 'cell'."
1.37 -
1.38 - level = self.match_group("level")
1.39 - feature = self.match_group("feature")
1.40 - self.region.extra = self.match_group("extra")
1.41 -
1.42 - if self.region.have_end(level):
1.43 - raise StopIteration
1.44 - else:
1.45 - cell.append_inline(Text(feature))
1.46
1.47 # Regular expressions.
1.48
1.49 @@ -122,7 +112,7 @@
1.50
1.51 # Pattern details.
1.52
1.53 - table_region_pattern_names = [
1.54 + region_pattern_names = [
1.55 "columnsep", "continuation", "rowsep",
1.56 ] + MoinParser.region_without_table_pattern_names
1.57
1.58 @@ -130,12 +120,15 @@
1.59
1.60 # Pattern handlers.
1.61
1.62 + end_region = MoinParser.end_region
1.63 + parse_table_end = MoinParser.parse_region_end
1.64 +
1.65 handlers = {}
1.66 handlers.update(MoinParser.handlers)
1.67 handlers.update({
1.68 - "columnsep" : MoinParser.end_region,
1.69 + "columnsep" : end_region,
1.70 "continuation" : parse_continuation,
1.71 - "rowsep" : MoinParser.end_region,
1.72 + "rowsep" : end_region,
1.73 "regionend" : parse_table_end,
1.74 })
1.75