paul@32 | 1 | #!/usr/bin/env python |
paul@32 | 2 | |
paul@32 | 3 | """ |
paul@32 | 4 | Moin wiki parsing functionality. |
paul@32 | 5 | |
paul@45 | 6 | Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> |
paul@32 | 7 | |
paul@32 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@32 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@32 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@32 | 11 | version. |
paul@32 | 12 | |
paul@32 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@32 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@32 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@32 | 16 | details. |
paul@32 | 17 | |
paul@32 | 18 | You should have received a copy of the GNU General Public License along with |
paul@32 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@32 | 20 | """ |
paul@32 | 21 | |
paul@43 | 22 | from collections import defaultdict |
paul@83 | 23 | from moinformat.tree.moin import Block, Region, Text |
paul@33 | 24 | import re |
paul@33 | 25 | |
paul@33 | 26 | # Pattern management. |
paul@33 | 27 | |
paul@36 | 28 | ws_excl_nl = r"[ \f\r\t\v]" |
paul@172 | 29 | quotes = "['" '"]' # ['"] |
paul@172 | 30 | dotall = r"(.|\n)" # behave similarly to dot with DOTALL option |
paul@172 | 31 | dotparagraph = r"(.|\n(?!\r?\n))" # match everything within paragraphs |
paul@55 | 32 | |
paul@121 | 33 | def choice(l): |
paul@121 | 34 | |
paul@121 | 35 | "Return a pattern matching a choice of patterns in 'l'." |
paul@121 | 36 | |
paul@121 | 37 | return "(%s)" % "|".join(l) |
paul@121 | 38 | |
paul@55 | 39 | def excl(s): |
paul@55 | 40 | |
paul@55 | 41 | "Return a non-matching pattern for 's'." |
paul@55 | 42 | |
paul@55 | 43 | return "(?!%s)" % s |
paul@55 | 44 | |
paul@55 | 45 | def expect(s): |
paul@55 | 46 | |
paul@55 | 47 | "Return a pattern expecting 's'." |
paul@55 | 48 | |
paul@55 | 49 | return "(?=%s)" % s |
paul@55 | 50 | |
paul@55 | 51 | def group(name, s): |
paul@55 | 52 | |
paul@58 | 53 | """ |
paul@58 | 54 | Return a pattern for the group having the given 'name' and employing the |
paul@58 | 55 | pattern string 's'. |
paul@58 | 56 | """ |
paul@55 | 57 | |
paul@55 | 58 | return "(?P<%s>%s)" % (name, s) |
paul@55 | 59 | |
paul@55 | 60 | def optional(s): |
paul@55 | 61 | |
paul@55 | 62 | "Return an optional pattern." |
paul@55 | 63 | |
paul@55 | 64 | return "(?:%s)?" % s |
paul@55 | 65 | |
paul@55 | 66 | def recur(name): |
paul@55 | 67 | |
paul@55 | 68 | "Return a test for a recurrence of group 'name'." |
paul@55 | 69 | |
paul@55 | 70 | return "(?P=%s)" % name |
paul@55 | 71 | |
paul@55 | 72 | def repeat(s, min=None, max=None): |
paul@55 | 73 | |
paul@55 | 74 | "Return a pattern matching 's' for the given 'min' and 'max' limits." |
paul@55 | 75 | |
paul@55 | 76 | return "%s{%s,%s}" % (s, min is not None and min or "", |
paul@55 | 77 | max is not None and max or "") |
paul@36 | 78 | |
paul@33 | 79 | def get_patterns(syntax): |
paul@33 | 80 | |
paul@36 | 81 | """ |
paul@36 | 82 | Define patterns for the regular expressions in the 'syntax' mapping. In each |
paul@58 | 83 | pattern, replace... |
paul@58 | 84 | |
paul@156 | 85 | \E with a pattern for matching all characters including newlines |
paul@58 | 86 | \N with a pattern for matching whitespace excluding newlines |
paul@173 | 87 | \P with a pattern for matching all characters within a paragraph |
paul@58 | 88 | \Q with a pattern for matching quotation marks |
paul@58 | 89 | |
paul@58 | 90 | Group names are also qualified with a pattern name prefix. |
paul@36 | 91 | """ |
paul@33 | 92 | |
paul@33 | 93 | patterns = {} |
paul@58 | 94 | |
paul@33 | 95 | for name, value in syntax.items(): |
paul@36 | 96 | value = value.replace(r"\N", ws_excl_nl) |
paul@55 | 97 | value = value.replace(r"\Q", quotes) |
paul@155 | 98 | value = value.replace(r"\E", dotall) |
paul@172 | 99 | value = value.replace(r"\P", dotparagraph) |
paul@58 | 100 | |
paul@58 | 101 | # Add the name to group names as a prefix. |
paul@58 | 102 | |
paul@58 | 103 | value = value.replace("(?P<", "(?P<%s_" % name) |
paul@58 | 104 | value = value.replace("(?P=", "(?P=%s_" % name) |
paul@58 | 105 | |
paul@58 | 106 | # Record the updated expression and add an identifying null group. |
paul@58 | 107 | |
paul@58 | 108 | patterns[name] = "%s(?P<group_%s>)" % (value, name) |
paul@58 | 109 | |
paul@33 | 110 | return patterns |
paul@33 | 111 | |
paul@58 | 112 | def get_expression(d, keys): |
paul@33 | 113 | |
paul@58 | 114 | """ |
paul@58 | 115 | Return a compiled expression combining patterns in 'd' having the given |
paul@58 | 116 | 'keys'. |
paul@58 | 117 | """ |
paul@36 | 118 | |
paul@58 | 119 | subset = [] |
paul@58 | 120 | |
paul@37 | 121 | for key in keys: |
paul@58 | 122 | subset.append(d[key]) |
paul@58 | 123 | |
paul@58 | 124 | return re.compile("|".join(subset), re.UNICODE | re.MULTILINE) |
paul@36 | 125 | |
paul@36 | 126 | |
paul@32 | 127 | |
paul@32 | 128 | # Tokenising functions. |
paul@32 | 129 | |
paul@32 | 130 | class TokenStream: |
paul@32 | 131 | |
paul@32 | 132 | "A stream of tokens taken from a string." |
paul@32 | 133 | |
paul@37 | 134 | def __init__(self, s, pos=0): |
paul@32 | 135 | self.s = s |
paul@36 | 136 | self.pos = pos |
paul@45 | 137 | |
paul@45 | 138 | # Match details. |
paul@45 | 139 | |
paul@32 | 140 | self.match = None |
paul@45 | 141 | self.queued = None |
paul@58 | 142 | self.groups = {} |
paul@45 | 143 | |
paul@45 | 144 | # Pattern name details. |
paul@45 | 145 | |
paul@32 | 146 | self.matching = None |
paul@32 | 147 | |
paul@32 | 148 | def rewind(self, length): |
paul@32 | 149 | |
paul@32 | 150 | "Rewind in the string by 'length'." |
paul@32 | 151 | |
paul@32 | 152 | self.pos -= min(length, self.pos) |
paul@32 | 153 | |
paul@45 | 154 | def queue_match(self): |
paul@45 | 155 | |
paul@45 | 156 | "Rewind in the string to the start of the last match." |
paul@45 | 157 | |
paul@45 | 158 | self.queued = self.match |
paul@45 | 159 | |
paul@58 | 160 | def read_until(self, expression, remaining=True): |
paul@32 | 161 | |
paul@32 | 162 | """ |
paul@58 | 163 | Find the first match for the given 'expression'. Return the text |
paul@58 | 164 | preceding any match, the remaining text if no match was found, or None |
paul@58 | 165 | if no match was found and 'remaining' is given as a false value. |
paul@32 | 166 | """ |
paul@32 | 167 | |
paul@45 | 168 | if self.queued: |
paul@45 | 169 | self.match = self.queued |
paul@45 | 170 | self.queued = None |
paul@45 | 171 | else: |
paul@45 | 172 | self.matching = None |
paul@32 | 173 | |
paul@45 | 174 | # Find the first matching pattern. |
paul@32 | 175 | |
paul@58 | 176 | match = expression.search(self.s, self.pos) |
paul@58 | 177 | |
paul@58 | 178 | if match: |
paul@58 | 179 | for name, value in match.groupdict().items(): |
paul@58 | 180 | |
paul@58 | 181 | # Use a group with a non-null value to identify the |
paul@58 | 182 | # matching pattern. |
paul@58 | 183 | |
paul@58 | 184 | if name.startswith("group_") and value is not None: |
paul@58 | 185 | self.matching = name[len("group_"):] |
paul@58 | 186 | self.start, self.end = match.span() |
paul@45 | 187 | self.match = match |
paul@58 | 188 | break |
paul@58 | 189 | |
paul@58 | 190 | # Return the remaining text, if appropriate. |
paul@32 | 191 | |
paul@32 | 192 | if self.matching is None: |
paul@58 | 193 | self.groups = {} |
paul@32 | 194 | if remaining: |
paul@32 | 195 | return self.s[self.pos:] |
paul@32 | 196 | else: |
paul@32 | 197 | return None |
paul@32 | 198 | else: |
paul@58 | 199 | self.groups = self.filter_groups() |
paul@45 | 200 | return self.s[self.pos:self.start] |
paul@32 | 201 | |
paul@58 | 202 | def filter_groups(self): |
paul@58 | 203 | |
paul@58 | 204 | "Filter groups from the current match for the matching pattern." |
paul@58 | 205 | |
paul@59 | 206 | prefix = "%s_" % self.matching |
paul@59 | 207 | |
paul@58 | 208 | d = {} |
paul@58 | 209 | for key, value in self.match.groupdict().items(): |
paul@59 | 210 | if key.startswith(prefix): |
paul@59 | 211 | d[key[len(prefix):]] = value |
paul@58 | 212 | return d |
paul@58 | 213 | |
paul@58 | 214 | def match_group(self, group=None): |
paul@32 | 215 | |
paul@32 | 216 | """ |
paul@32 | 217 | Return the matched text, updating the position in the stream. If 'group' |
paul@32 | 218 | is specified, the indicated group in a match will be returned. |
paul@58 | 219 | Otherwise, the entire match is returned. |
paul@32 | 220 | """ |
paul@32 | 221 | |
paul@54 | 222 | self.update_pos() |
paul@54 | 223 | |
paul@32 | 224 | if self.match: |
paul@58 | 225 | if group is None: |
paul@58 | 226 | return self.s[self.start:self.end] |
paul@58 | 227 | else: |
paul@59 | 228 | return self.groups.get(group) |
paul@32 | 229 | else: |
paul@32 | 230 | return None |
paul@32 | 231 | |
paul@54 | 232 | def match_groups(self, groups=None): |
paul@51 | 233 | |
paul@54 | 234 | "Return the match 'groups', or all groups if unspecified." |
paul@54 | 235 | |
paul@54 | 236 | self.update_pos() |
paul@51 | 237 | |
paul@51 | 238 | if self.match: |
paul@54 | 239 | if groups is None: |
paul@58 | 240 | return self.groups |
paul@54 | 241 | else: |
paul@58 | 242 | l = [] |
paul@58 | 243 | for group in groups: |
paul@59 | 244 | l.append(self.groups.get(group)) |
paul@58 | 245 | return l |
paul@51 | 246 | else: |
paul@51 | 247 | return [] |
paul@51 | 248 | |
paul@54 | 249 | def update_pos(self): |
paul@54 | 250 | |
paul@54 | 251 | "Update the position in the stream." |
paul@54 | 252 | |
paul@54 | 253 | if self.match: |
paul@54 | 254 | _start, self.pos = self.match.span() |
paul@54 | 255 | else: |
paul@54 | 256 | self.pos = len(self.s) |
paul@54 | 257 | |
paul@32 | 258 | |
paul@32 | 259 | |
paul@32 | 260 | # Parser abstractions. |
paul@32 | 261 | |
paul@32 | 262 | class ParserBase: |
paul@32 | 263 | |
paul@32 | 264 | "Common parsing methods." |
paul@32 | 265 | |
paul@37 | 266 | region_pattern_names = None |
paul@37 | 267 | |
paul@165 | 268 | def __init__(self, metadata, parsers=None, root=None): |
paul@32 | 269 | |
paul@32 | 270 | """ |
paul@165 | 271 | Initialise the parser with the given 'metadata' and optional 'parsers'. |
paul@165 | 272 | An optional 'root' indicates the document-level parser. |
paul@32 | 273 | """ |
paul@32 | 274 | |
paul@165 | 275 | self.metadata = metadata |
paul@165 | 276 | self.parsers = parsers |
paul@87 | 277 | self.root = root |
paul@37 | 278 | |
paul@37 | 279 | def get_parser(self, format_type): |
paul@37 | 280 | |
paul@37 | 281 | """ |
paul@37 | 282 | Return a parser for 'format_type' or None if no suitable parser is found. |
paul@37 | 283 | """ |
paul@37 | 284 | |
paul@165 | 285 | cls = self.parsers and self.parsers.get(format_type) |
paul@37 | 286 | if cls: |
paul@165 | 287 | return cls(self.metadata, self.parsers, self.root or self) |
paul@37 | 288 | else: |
paul@37 | 289 | return None |
paul@37 | 290 | |
paul@58 | 291 | def get_expression(self, pattern_names): |
paul@37 | 292 | |
paul@37 | 293 | "Return a mapping of the given 'pattern_names' to patterns." |
paul@37 | 294 | |
paul@58 | 295 | return get_expression(self.patterns, pattern_names) |
paul@32 | 296 | |
paul@36 | 297 | def get_items(self, s, pos=0): |
paul@32 | 298 | |
paul@36 | 299 | "Return a sequence of token items for 's' and 'pos'." |
paul@32 | 300 | |
paul@37 | 301 | return TokenStream(s, pos) |
paul@37 | 302 | |
paul@37 | 303 | def set_region(self, items, region): |
paul@37 | 304 | |
paul@37 | 305 | "Set the 'items' used to populate the given 'region'." |
paul@32 | 306 | |
paul@37 | 307 | self.items = items |
paul@37 | 308 | self.region = region |
paul@37 | 309 | |
paul@37 | 310 | def read_until(self, pattern_names, remaining=True): |
paul@36 | 311 | |
paul@37 | 312 | """ |
paul@37 | 313 | Read the next portion of input, matching using 'pattern_names'. Return |
paul@37 | 314 | the text preceding any match, the remaining text if no match was found, |
paul@37 | 315 | or None if no match was found and 'remaining' is given as a false value. |
paul@37 | 316 | """ |
paul@36 | 317 | |
paul@58 | 318 | return self.items.read_until(self.get_expression(pattern_names)) |
paul@37 | 319 | |
paul@58 | 320 | def match_group(self, group=None): |
paul@37 | 321 | |
paul@37 | 322 | """ |
paul@58 | 323 | Return the group of the matching pattern with the given 'group' |
paul@58 | 324 | identifier. If 'group' is omitted or None, return the entire match. |
paul@37 | 325 | """ |
paul@36 | 326 | |
paul@54 | 327 | return self.items.match_group(group) |
paul@37 | 328 | |
paul@54 | 329 | def matching_pattern(self): |
paul@36 | 330 | |
paul@37 | 331 | "Return the name of the matching pattern." |
paul@36 | 332 | |
paul@37 | 333 | return self.items.matching |
paul@37 | 334 | |
paul@51 | 335 | def match_groups(self): |
paul@51 | 336 | |
paul@51 | 337 | "Return the number of groups in the match." |
paul@51 | 338 | |
paul@51 | 339 | return self.items.match_groups() |
paul@51 | 340 | |
paul@37 | 341 | # Parser methods invoked from other objects. |
paul@36 | 342 | |
paul@32 | 343 | def parse(self, s): |
paul@32 | 344 | |
paul@32 | 345 | """ |
paul@32 | 346 | Parse page text 's'. Pages consist of regions delimited by markers. |
paul@32 | 347 | """ |
paul@32 | 348 | |
paul@37 | 349 | self.items = self.get_items(s) |
paul@37 | 350 | self.region = self.parse_region() |
paul@37 | 351 | return self.region |
paul@37 | 352 | |
paul@37 | 353 | def parse_region_content(self, items, region): |
paul@37 | 354 | |
paul@37 | 355 | "Parse the data provided by 'items' to populate a 'region'." |
paul@37 | 356 | |
paul@37 | 357 | self.set_region(items, region) |
paul@32 | 358 | |
paul@70 | 359 | # Parse inline and opaque regions. |
paul@70 | 360 | |
paul@70 | 361 | if not region.transparent: |
paul@70 | 362 | pattern_names = ["regionend"] |
paul@70 | 363 | |
paul@70 | 364 | # Define a block to hold text. |
paul@70 | 365 | |
paul@70 | 366 | else: |
paul@70 | 367 | self.new_block(region) |
paul@70 | 368 | pattern_names = self.region_pattern_names |
paul@37 | 369 | |
paul@70 | 370 | # Start parsing. |
paul@70 | 371 | |
paul@70 | 372 | if pattern_names: |
paul@70 | 373 | self.parse_region_details(region, pattern_names) |
paul@37 | 374 | |
paul@70 | 375 | # Reset the type if the region was not inline. |
paul@70 | 376 | |
paul@70 | 377 | if region.type == "inline": |
paul@70 | 378 | first = region.nodes and region.nodes[0] |
paul@70 | 379 | if first and isinstance(first, Text) and first.multiline(): |
paul@70 | 380 | region.type = None |
paul@37 | 381 | |
paul@37 | 382 | # Top-level parser handler methods. |
paul@37 | 383 | |
paul@52 | 384 | def parse_region(self, level=0, indent=0, type=None): |
paul@32 | 385 | |
paul@32 | 386 | """ |
paul@37 | 387 | Parse the data to populate a region with the given 'level' at the given |
paul@52 | 388 | 'indent' having the given initial 'type'. |
paul@32 | 389 | """ |
paul@32 | 390 | |
paul@52 | 391 | region = Region([], level, indent, type) |
paul@32 | 392 | |
paul@151 | 393 | # Parse section headers and directives, then parse according to region |
paul@151 | 394 | # type. |
paul@32 | 395 | |
paul@37 | 396 | self.parse_region_header(region) |
paul@151 | 397 | self.parse_region_directives(region) |
paul@37 | 398 | self.parse_region_type(region) |
paul@32 | 399 | |
paul@32 | 400 | return region |
paul@32 | 401 | |
paul@37 | 402 | def parse_region_type(self, region): |
paul@32 | 403 | |
paul@32 | 404 | """ |
paul@37 | 405 | Use configured parsers to parse 'region' based on its type. |
paul@32 | 406 | """ |
paul@32 | 407 | |
paul@32 | 408 | # Find an appropriate parser given the type. |
paul@32 | 409 | |
paul@37 | 410 | parser = self.get_parser(region.type) |
paul@70 | 411 | if not parser: |
paul@70 | 412 | region.transparent = False |
paul@70 | 413 | parser = parser or self.get_parser("moin") |
paul@70 | 414 | parser.parse_region_content(self.items, region) |
paul@32 | 415 | |
paul@37 | 416 | def parse_region_header(self, region): |
paul@32 | 417 | |
paul@32 | 418 | """ |
paul@37 | 419 | Parse the region header, setting it on the 'region' object. |
paul@32 | 420 | """ |
paul@32 | 421 | |
paul@37 | 422 | if self.read_until(["header"], False) == "": # None means no header |
paul@124 | 423 | region.args = self.match_group("args") |
paul@124 | 424 | region.type = region.args.split(" ", 1)[0] |
paul@32 | 425 | |
paul@151 | 426 | def parse_region_directives(self, region): |
paul@151 | 427 | |
paul@151 | 428 | """ |
paul@151 | 429 | Parse any directives immediately after the region header, adding them to |
paul@151 | 430 | the 'region' object. |
paul@151 | 431 | """ |
paul@151 | 432 | |
paul@151 | 433 | while True: |
paul@151 | 434 | preceding = self.read_until(["directive"], False) |
paul@151 | 435 | |
paul@151 | 436 | # With an immediately-appearing directive, handle its details. |
paul@151 | 437 | |
paul@151 | 438 | if preceding == "": |
paul@151 | 439 | handler = self.handlers.get(self.matching_pattern()) |
paul@151 | 440 | if handler: |
paul@151 | 441 | handler(self, region) |
paul@151 | 442 | else: |
paul@151 | 443 | break |
paul@151 | 444 | |
paul@151 | 445 | # Otherwise, with no immediate directive (or none at all), stop. |
paul@151 | 446 | |
paul@151 | 447 | else: |
paul@151 | 448 | break |
paul@151 | 449 | |
paul@32 | 450 | # Parsing utilities. |
paul@32 | 451 | |
paul@43 | 452 | def parse_region_details(self, region, pattern_names, strict=False): |
paul@32 | 453 | |
paul@43 | 454 | """ |
paul@43 | 455 | Search 'region' using the 'pattern_names'. If 'strict' is set to a true |
paul@43 | 456 | value, forbid the accumulation of additional textual padding. |
paul@43 | 457 | """ |
paul@32 | 458 | |
paul@32 | 459 | try: |
paul@32 | 460 | while True: |
paul@32 | 461 | |
paul@32 | 462 | # Obtain text before any marker or the end of the input. |
paul@32 | 463 | |
paul@37 | 464 | preceding = self.read_until(pattern_names) |
paul@32 | 465 | if preceding: |
paul@43 | 466 | if not strict: |
paul@43 | 467 | region.append_inline(Text(preceding)) |
paul@43 | 468 | else: |
paul@43 | 469 | break |
paul@32 | 470 | |
paul@32 | 471 | # End of input. |
paul@32 | 472 | |
paul@54 | 473 | if not self.matching_pattern(): |
paul@32 | 474 | break |
paul@32 | 475 | |
paul@32 | 476 | # Obtain any feature. |
paul@32 | 477 | |
paul@67 | 478 | feature = self.match_group("feature") or self.match_group() |
paul@54 | 479 | handler = self.handlers.get(self.matching_pattern()) |
paul@32 | 480 | |
paul@32 | 481 | # Handle each feature or add text to the region. |
paul@32 | 482 | |
paul@32 | 483 | if handler: |
paul@37 | 484 | handler(self, region) |
paul@43 | 485 | elif not strict: |
paul@43 | 486 | region.append_inline(Text(feature)) |
paul@32 | 487 | else: |
paul@43 | 488 | break |
paul@32 | 489 | |
paul@32 | 490 | except StopIteration: |
paul@32 | 491 | pass |
paul@32 | 492 | |
paul@32 | 493 | region.normalise() |
paul@32 | 494 | |
paul@43 | 495 | def add_node(self, region, node): |
paul@43 | 496 | |
paul@43 | 497 | "Add to 'region' the given 'node'." |
paul@43 | 498 | |
paul@43 | 499 | region.add(node) |
paul@43 | 500 | |
paul@43 | 501 | def append_node(self, region, node): |
paul@43 | 502 | |
paul@43 | 503 | "Append to 'region' the given 'node'." |
paul@43 | 504 | |
paul@43 | 505 | region.append(node) |
paul@43 | 506 | |
paul@37 | 507 | def end_region(self, region): |
paul@32 | 508 | |
paul@32 | 509 | "End the parsing of 'region', breaking out of the parsing loop." |
paul@32 | 510 | |
paul@32 | 511 | raise StopIteration |
paul@32 | 512 | |
paul@45 | 513 | def queue_match(self): |
paul@43 | 514 | |
paul@45 | 515 | "Queue the current match." |
paul@43 | 516 | |
paul@45 | 517 | self.items.queue_match() |
paul@43 | 518 | |
paul@43 | 519 | def new_block(self, region): |
paul@43 | 520 | |
paul@43 | 521 | "Start a new block in 'region'." |
paul@43 | 522 | |
paul@43 | 523 | self.add_node(region, Block([])) |
paul@43 | 524 | |
paul@98 | 525 | # Common handler methods. |
paul@98 | 526 | |
paul@98 | 527 | def parse_region_end(self, node): |
paul@98 | 528 | |
paul@98 | 529 | "Handle the end of a region occurring within 'node'." |
paul@98 | 530 | |
paul@98 | 531 | level = self.match_group("level") |
paul@98 | 532 | feature = self.match_group("feature") |
paul@98 | 533 | self.region.extra = self.match_group("extra") |
paul@98 | 534 | |
paul@98 | 535 | if self.region.have_end(level): |
paul@98 | 536 | raise StopIteration |
paul@98 | 537 | else: |
paul@98 | 538 | node.append_inline(Text(feature)) |
paul@98 | 539 | |
paul@32 | 540 | # vim: tabstop=4 expandtab shiftwidth=4 |