paul@0 | 1 | #!/usr/bin/env python |
paul@0 | 2 | |
paul@0 | 3 | """ |
paul@0 | 4 | Moin wiki format parser. |
paul@0 | 5 | |
paul@192 | 6 | Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 7 | |
paul@0 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@0 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@0 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@0 | 11 | version. |
paul@0 | 12 | |
paul@0 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@0 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@0 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@0 | 16 | details. |
paul@0 | 17 | |
paul@0 | 18 | You should have received a copy of the GNU General Public License along with |
paul@0 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@0 | 20 | """ |
paul@0 | 21 | |
paul@91 | 22 | # Document transformations. |
paul@91 | 23 | |
paul@89 | 24 | from moinformat.macros import get_macro |
paul@91 | 25 | |
paul@91 | 26 | # Parser functionality and pattern definition. |
paul@91 | 27 | |
paul@122 | 28 | from moinformat.parsers.common import ParserBase, get_patterns, choice, \ |
paul@83 | 29 | excl, expect, group, optional, recur, \ |
paul@83 | 30 | repeat |
paul@91 | 31 | |
paul@91 | 32 | # Serialisation. |
paul@91 | 33 | |
paul@28 | 34 | from moinformat.serialisers import serialise |
paul@91 | 35 | |
paul@91 | 36 | # Document tree nodes. |
paul@91 | 37 | |
paul@151 | 38 | from moinformat.tree.moin import Anchor, Break, Comment, DefItem, DefTerm, \ |
paul@151 | 39 | Directive, FontStyle, Heading, Larger, \ |
paul@167 | 40 | LineBreak, Link, LinkLabel, LinkParameter, \ |
paul@167 | 41 | List, ListItem, Macro, Monospace, Region, \ |
paul@167 | 42 | Rule, Smaller, Strikethrough, Subscript, \ |
paul@167 | 43 | Superscript, Table, TableAttr, TableAttrs, \ |
paul@167 | 44 | TableCell, TableRow, Text, Transclusion, \ |
paul@169 | 45 | Underline, Verbatim |
paul@32 | 46 | |
paul@222 | 47 | # Link parsing. |
paul@222 | 48 | |
paul@222 | 49 | from moinformat.utils.links import parse_link_target |
paul@222 | 50 | |
paul@55 | 51 | join = "".join |
paul@55 | 52 | |
paul@42 | 53 | class MoinParser(ParserBase): |
paul@2 | 54 | |
paul@32 | 55 | "A wiki region parser." |
paul@2 | 56 | |
paul@109 | 57 | format = "moin" |
paul@109 | 58 | |
paul@165 | 59 | def __init__(self, metadata, parsers=None, root=None): |
paul@2 | 60 | |
paul@2 | 61 | """ |
paul@165 | 62 | Initialise the parser with the given 'metadata' and optional 'parsers'. |
paul@165 | 63 | An optional 'root' indicates the document-level parser. |
paul@2 | 64 | """ |
paul@2 | 65 | |
paul@165 | 66 | ParserBase.__init__(self, metadata, parsers, root) |
paul@87 | 67 | |
paul@91 | 68 | # Record certain node occurrences for later evaluation. |
paul@87 | 69 | |
paul@87 | 70 | self.macros = [] |
paul@2 | 71 | |
paul@128 | 72 | # Record headings for identifier disambiguation. |
paul@128 | 73 | |
paul@128 | 74 | self.headings = [] |
paul@128 | 75 | |
paul@222 | 76 | # Record link targets for resource identification. |
paul@222 | 77 | |
paul@222 | 78 | self.link_targets = [] |
paul@222 | 79 | |
paul@33 | 80 | # Principal parser methods. |
paul@33 | 81 | |
paul@32 | 82 | def parse(self, s): |
paul@1 | 83 | |
paul@31 | 84 | """ |
paul@31 | 85 | Parse page text 's'. Pages consist of regions delimited by markers. |
paul@31 | 86 | """ |
paul@1 | 87 | |
paul@37 | 88 | self.items = self.get_items(s) |
paul@52 | 89 | self.region = Region([], type="moin") |
paul@2 | 90 | |
paul@151 | 91 | # Parse page header and directives. |
paul@31 | 92 | |
paul@37 | 93 | self.parse_region_header(self.region) |
paul@151 | 94 | self.parse_region_directives(self.region) |
paul@31 | 95 | |
paul@37 | 96 | # Handle pages directly with this parser. Pages do not need to use an |
paul@37 | 97 | # explicit format indicator. |
paul@37 | 98 | |
paul@37 | 99 | if not self.region.type: |
paul@37 | 100 | self.parse_region_content(self.items, self.region) |
paul@37 | 101 | |
paul@32 | 102 | # Otherwise, test the type and find an appropriate parser. |
paul@2 | 103 | |
paul@31 | 104 | else: |
paul@37 | 105 | self.parse_region_type(self.region) |
paul@0 | 106 | |
paul@128 | 107 | # Assign heading identifiers. |
paul@128 | 108 | |
paul@128 | 109 | self.identify_headings() |
paul@128 | 110 | |
paul@37 | 111 | return self.region |
paul@36 | 112 | |
paul@0 | 113 | |
paul@36 | 114 | |
paul@89 | 115 | # Macro evaluation. |
paul@89 | 116 | |
paul@89 | 117 | def evaluate_macros(self): |
paul@89 | 118 | |
paul@89 | 119 | "Evaluate the macro nodes in the document." |
paul@89 | 120 | |
paul@89 | 121 | for node in self.macros: |
paul@89 | 122 | |
paul@89 | 123 | # Obtain a class for the named macro. |
paul@89 | 124 | |
paul@89 | 125 | macro_cls = get_macro(node.name) |
paul@89 | 126 | if not macro_cls: |
paul@89 | 127 | continue |
paul@89 | 128 | |
paul@89 | 129 | # Instantiate the class and evaluate the macro. |
paul@89 | 130 | |
paul@89 | 131 | macro = macro_cls(node, self.region) |
paul@89 | 132 | macro.evaluate() |
paul@89 | 133 | |
paul@199 | 134 | # Metadata extraction. |
paul@199 | 135 | |
paul@199 | 136 | def update_metadata(self, metadata): |
paul@199 | 137 | |
paul@199 | 138 | "Update 'metadata' for the document." |
paul@199 | 139 | |
paul@199 | 140 | if self.headings: |
paul@199 | 141 | metadata.set("title", self.headings[0].text_content()) |
paul@199 | 142 | |
paul@128 | 143 | # Heading disambiguation. |
paul@128 | 144 | |
paul@128 | 145 | def identify_headings(self): |
paul@128 | 146 | |
paul@128 | 147 | "Assign identifiers to headings based on their textual content." |
paul@128 | 148 | |
paul@128 | 149 | d = {} |
paul@128 | 150 | |
paul@128 | 151 | for heading in self.headings: |
paul@128 | 152 | text = heading.text_content() |
paul@128 | 153 | |
paul@128 | 154 | if not d.has_key(text): |
paul@128 | 155 | d[text] = 0 |
paul@128 | 156 | heading.identifier = text |
paul@128 | 157 | else: |
paul@128 | 158 | d[text] += 1 |
paul@128 | 159 | heading.identifier = "%s-%d" % (text, d[text]) |
paul@128 | 160 | |
paul@89 | 161 | |
paul@89 | 162 | |
paul@165 | 163 | # Conversion back to text. |
paul@165 | 164 | |
paul@165 | 165 | def get_serialiser(self): |
paul@165 | 166 | |
paul@165 | 167 | "Return metadata employing Moin as the output format." |
paul@165 | 168 | |
paul@165 | 169 | metadata = self.metadata.copy() |
paul@165 | 170 | metadata.set("link_format", None) |
paul@165 | 171 | metadata.set("output_context", "standalone") |
paul@165 | 172 | metadata.set("output_format", "moin") |
paul@165 | 173 | return metadata.get_serialiser() |
paul@165 | 174 | |
paul@165 | 175 | |
paul@165 | 176 | |
paul@31 | 177 | # Parser methods supporting different page features. |
paul@31 | 178 | |
paul@37 | 179 | def parse_attrname(self, attrs): |
paul@31 | 180 | |
paul@31 | 181 | "Handle an attribute name within 'attrs'." |
paul@8 | 182 | |
paul@55 | 183 | name = self.match_group("name") |
paul@31 | 184 | attr = TableAttr(name) |
paul@1 | 185 | |
paul@37 | 186 | preceding = self.read_until(["attrvalue"], False) |
paul@31 | 187 | if preceding == "": |
paul@55 | 188 | attr.quote = self.match_group("quote") |
paul@55 | 189 | attr.value = self.match_group("value") |
paul@25 | 190 | |
paul@31 | 191 | attrs.append(attr) |
paul@31 | 192 | |
paul@37 | 193 | def parse_break(self, region): |
paul@25 | 194 | |
paul@31 | 195 | "Handle a paragraph break within 'region'." |
paul@31 | 196 | |
paul@43 | 197 | self.add_node(region, Break()) |
paul@43 | 198 | self.new_block(region) |
paul@31 | 199 | |
paul@151 | 200 | def parse_comment(self, region): |
paul@151 | 201 | |
paul@151 | 202 | "Handle a comment within 'region'." |
paul@151 | 203 | |
paul@151 | 204 | comment = self.match_group("comment") |
paul@151 | 205 | extra = self.match_group("extra") |
paul@151 | 206 | self.add_node(region, Comment(comment, extra)) |
paul@151 | 207 | self.new_block(region) |
paul@151 | 208 | |
paul@37 | 209 | def parse_defitem(self, region, extra=""): |
paul@25 | 210 | |
paul@31 | 211 | "Handle a definition item within 'region'." |
paul@25 | 212 | |
paul@55 | 213 | pad = self.match_group("pad") |
paul@31 | 214 | item = DefItem([], pad, extra) |
paul@123 | 215 | self.parse_region_details(item, self.listitem_pattern_names) |
paul@43 | 216 | self.add_node(region, item) |
paul@43 | 217 | self.new_block(region) |
paul@8 | 218 | |
paul@37 | 219 | def parse_defterm(self, region): |
paul@31 | 220 | |
paul@31 | 221 | "Handle a definition term within 'region'." |
paul@7 | 222 | |
paul@55 | 223 | pad = self.match_group("pad") |
paul@31 | 224 | term = DefTerm([], pad) |
paul@37 | 225 | self.parse_region_details(term, ["deftermend", "deftermsep"]) |
paul@43 | 226 | self.add_node(region, term) |
paul@122 | 227 | |
paul@54 | 228 | if self.matching_pattern() == "deftermsep": |
paul@37 | 229 | self.parse_defitem(region) |
paul@16 | 230 | |
paul@122 | 231 | # Add padding from the separator to the term, there being no item. |
paul@122 | 232 | |
paul@122 | 233 | else: |
paul@122 | 234 | term.extra = self.match_group("pad") |
paul@122 | 235 | |
paul@37 | 236 | def parse_defterm_empty(self, region): |
paul@31 | 237 | |
paul@31 | 238 | "Handle an empty definition term within 'region'." |
paul@16 | 239 | |
paul@55 | 240 | extra = self.match_group("pad") |
paul@37 | 241 | self.parse_region_details(region, ["deftermsep"]) |
paul@37 | 242 | self.parse_defitem(region, extra) |
paul@16 | 243 | |
paul@151 | 244 | def parse_directive(self, region): |
paul@151 | 245 | |
paul@151 | 246 | "Handle a processing directive within 'region'." |
paul@151 | 247 | |
paul@151 | 248 | directive = self.match_group("directive") |
paul@151 | 249 | extra = self.match_group("extra") |
paul@151 | 250 | self.add_node(region, Directive(directive, extra)) |
paul@151 | 251 | self.new_block(region) |
paul@151 | 252 | |
paul@37 | 253 | def parse_fontstyle(self, region): |
paul@31 | 254 | |
paul@31 | 255 | "Handle emphasis and strong styles." |
paul@16 | 256 | |
paul@55 | 257 | n = len(self.match_group("style")) |
paul@31 | 258 | |
paul@31 | 259 | # Handle endings. |
paul@16 | 260 | |
paul@31 | 261 | if isinstance(region, FontStyle): |
paul@31 | 262 | emphasis = n in (2, 4, 5) |
paul@31 | 263 | strong = n in (3, 5, 6) |
paul@31 | 264 | active = True |
paul@16 | 265 | |
paul@31 | 266 | if region.emphasis and emphasis: |
paul@31 | 267 | active = region.close_emphasis() |
paul@31 | 268 | n -= 2 |
paul@31 | 269 | if region.strong and strong: |
paul@31 | 270 | active = region.close_strong() |
paul@31 | 271 | n -= 3 |
paul@18 | 272 | |
paul@31 | 273 | if not active: |
paul@31 | 274 | if n: |
paul@37 | 275 | self.items.rewind(n) |
paul@31 | 276 | raise StopIteration |
paul@18 | 277 | |
paul@31 | 278 | elif not n: |
paul@31 | 279 | return |
paul@18 | 280 | |
paul@31 | 281 | # Handle new styles. |
paul@31 | 282 | |
paul@18 | 283 | emphasis = n in (2, 4, 5) |
paul@18 | 284 | strong = n in (3, 5, 6) |
paul@31 | 285 | double = n in (4, 6) |
paul@31 | 286 | |
paul@31 | 287 | span = FontStyle([], emphasis, strong) |
paul@31 | 288 | if not double: |
paul@37 | 289 | self.parse_region_details(span, self.inline_pattern_names) |
paul@31 | 290 | region.append_inline(span) |
paul@31 | 291 | |
paul@37 | 292 | def parse_halign(self, attrs): |
paul@31 | 293 | |
paul@31 | 294 | "Handle horizontal alignment within 'attrs'." |
paul@31 | 295 | |
paul@55 | 296 | value = self.match_group("value") |
paul@202 | 297 | attr = TableAttr("align", value == "(" and "left" or value == ")" and "right" or "center", True) |
paul@31 | 298 | attrs.append(attr) |
paul@31 | 299 | |
paul@37 | 300 | def parse_heading(self, region): |
paul@17 | 301 | |
paul@31 | 302 | "Handle a heading." |
paul@18 | 303 | |
paul@55 | 304 | start_extra = self.match_group("extra") |
paul@55 | 305 | level = len(self.match_group("level")) |
paul@55 | 306 | start_pad = self.match_group("pad") |
paul@31 | 307 | heading = Heading([], level, start_extra, start_pad) |
paul@37 | 308 | self.parse_region_details(heading, ["headingend"] + self.inline_pattern_names) |
paul@43 | 309 | self.add_node(region, heading) |
paul@43 | 310 | self.new_block(region) |
paul@31 | 311 | |
paul@128 | 312 | # Record the heading for later processing. |
paul@128 | 313 | |
paul@128 | 314 | self.root.headings.append(heading) |
paul@128 | 315 | |
paul@37 | 316 | def parse_heading_end(self, heading): |
paul@31 | 317 | |
paul@31 | 318 | "Handle the end of a heading." |
paul@31 | 319 | |
paul@55 | 320 | level = len(self.match_group("level")) |
paul@31 | 321 | if heading.level == level: |
paul@55 | 322 | heading.end_pad = self.match_group("pad") |
paul@55 | 323 | heading.end_extra = self.match_group("extra") |
paul@18 | 324 | raise StopIteration |
paul@17 | 325 | |
paul@43 | 326 | def parse_list(self, item): |
paul@43 | 327 | |
paul@43 | 328 | "Create a list, starting with 'item'." |
paul@43 | 329 | |
paul@51 | 330 | list = List([item], item.indent, item.marker, item.num) |
paul@43 | 331 | self.parse_region_details(list, self.list_pattern_names, True) |
paul@43 | 332 | return list |
paul@43 | 333 | |
paul@37 | 334 | def parse_listitem(self, region): |
paul@31 | 335 | |
paul@31 | 336 | "Handle a list item marker within 'region'." |
paul@31 | 337 | |
paul@55 | 338 | indent = len(self.match_group("indent")) |
paul@55 | 339 | marker = self.match_group("marker") |
paul@55 | 340 | num = self.match_group("num") |
paul@55 | 341 | space = self.match_group("pad") |
paul@43 | 342 | |
paul@45 | 343 | last = region.node(-1) |
paul@45 | 344 | |
paul@51 | 345 | new_list = not isinstance(last, (List, ListItem)) |
paul@51 | 346 | same_indent = not new_list and indent == last.indent |
paul@51 | 347 | new_marker = not new_list and last.marker != marker and same_indent |
paul@51 | 348 | new_num = not new_list and num is not None and last.num != num and same_indent |
paul@51 | 349 | |
paul@51 | 350 | # If the marker or number changes at the same indent, or if the indent |
paul@49 | 351 | # is smaller, queue the item and end the list. |
paul@45 | 352 | |
paul@51 | 353 | # Note that Moin format does not seek to support item renumbering, |
paul@51 | 354 | # instead starting new lists on number changes. |
paul@51 | 355 | |
paul@51 | 356 | if not new_list and (new_marker or new_num or indent < last.indent): |
paul@45 | 357 | self.queue_match() |
paul@45 | 358 | self.end_region(region) |
paul@45 | 359 | |
paul@45 | 360 | # Obtain a list item and populate it. |
paul@45 | 361 | |
paul@51 | 362 | item = ListItem([], indent, marker, space, num) |
paul@37 | 363 | self.parse_region_details(item, self.listitem_pattern_names) |
paul@43 | 364 | |
paul@49 | 365 | # Start a new list if not preceded by a list item, adding a trailing |
paul@49 | 366 | # block for new elements. |
paul@43 | 367 | |
paul@49 | 368 | if new_list: |
paul@49 | 369 | item = self.parse_list(item) |
paul@45 | 370 | self.add_node(region, item) |
paul@49 | 371 | self.new_block(region) |
paul@43 | 372 | |
paul@49 | 373 | # Add a nested list to the last item. |
paul@49 | 374 | |
paul@49 | 375 | elif indent > last.indent: |
paul@49 | 376 | item = self.parse_list(item) |
paul@49 | 377 | self.add_node(last, item) |
paul@43 | 378 | |
paul@45 | 379 | # Add the item to the current list. |
paul@43 | 380 | |
paul@45 | 381 | else: |
paul@45 | 382 | self.add_node(region, item) |
paul@31 | 383 | |
paul@37 | 384 | def parse_rule(self, region): |
paul@31 | 385 | |
paul@31 | 386 | "Handle a horizontal rule within 'region'." |
paul@31 | 387 | |
paul@55 | 388 | length = len(self.match_group("rule")) |
paul@31 | 389 | rule = Rule(length) |
paul@43 | 390 | self.add_node(region, rule) |
paul@43 | 391 | self.new_block(region) |
paul@31 | 392 | |
paul@37 | 393 | def parse_section(self, region): |
paul@31 | 394 | |
paul@31 | 395 | "Handle the start of a new section within 'region'." |
paul@31 | 396 | |
paul@31 | 397 | # Parse the section and start a new block after the section. |
paul@31 | 398 | |
paul@55 | 399 | indent = len(self.match_group("indent")) |
paul@55 | 400 | level = len(self.match_group("level")) |
paul@67 | 401 | |
paul@67 | 402 | section = self.parse_region(level, indent, "inline") |
paul@67 | 403 | |
paul@67 | 404 | # If the section is inline, treat it like any other inline element. |
paul@67 | 405 | |
paul@67 | 406 | if section.type == "inline": |
paul@67 | 407 | region.append_inline(section) |
paul@67 | 408 | |
paul@67 | 409 | # Otherwise, add it as a new block element. |
paul@67 | 410 | |
paul@67 | 411 | else: |
paul@67 | 412 | self.add_node(region, section) |
paul@67 | 413 | if region.allow_blocks: |
paul@67 | 414 | self.new_block(region) |
paul@31 | 415 | |
paul@37 | 416 | def parse_table_attrs(self, cell): |
paul@31 | 417 | |
paul@31 | 418 | "Handle the start of table attributes within 'cell'." |
paul@31 | 419 | |
paul@31 | 420 | attrs = TableAttrs([]) |
paul@102 | 421 | self.parse_region_details(attrs, self.table_attr_pattern_names) |
paul@31 | 422 | |
paul@31 | 423 | # Test the validity of the attributes. |
paul@31 | 424 | |
paul@31 | 425 | last = None |
paul@31 | 426 | |
paul@31 | 427 | for node in attrs.nodes: |
paul@31 | 428 | |
paul@31 | 429 | # Text separator nodes must be whitespace. |
paul@31 | 430 | |
paul@31 | 431 | if isinstance(node, Text): |
paul@31 | 432 | if node.s.strip(): |
paul@31 | 433 | break |
paul@31 | 434 | |
paul@31 | 435 | # Named attributes must be preceded by space if not the first. |
paul@31 | 436 | |
paul@31 | 437 | elif last and not node.concise and not isinstance(last, Text): |
paul@31 | 438 | break |
paul@31 | 439 | |
paul@31 | 440 | last = node |
paul@31 | 441 | |
paul@31 | 442 | # All nodes were valid: preserve the collection. |
paul@31 | 443 | |
paul@31 | 444 | else: |
paul@67 | 445 | # Add the attributes as a node, also recording their presence. |
paul@67 | 446 | |
paul@67 | 447 | cell.append(attrs) |
paul@31 | 448 | cell.attrs = attrs |
paul@18 | 449 | return |
paul@18 | 450 | |
paul@31 | 451 | # Invalid nodes were found: serialise the attributes as text. |
paul@18 | 452 | |
paul@165 | 453 | cell.append_inline(Text(serialise(attrs, self.get_serialiser()))) |
paul@25 | 454 | |
paul@37 | 455 | def parse_table_row(self, region): |
paul@9 | 456 | |
paul@31 | 457 | "Handle the start of a table row within 'region'." |
paul@9 | 458 | |
paul@36 | 459 | # Identify any active table. |
paul@36 | 460 | |
paul@36 | 461 | table = region.node(-2) |
paul@36 | 462 | block = region.node(-1) |
paul@36 | 463 | |
paul@36 | 464 | if not (isinstance(table, Table) and block.empty()): |
paul@36 | 465 | new_table = table = Table([]) |
paul@36 | 466 | else: |
paul@36 | 467 | new_table = None |
paul@36 | 468 | |
paul@31 | 469 | row = TableRow([]) |
paul@9 | 470 | |
paul@31 | 471 | while True: |
paul@31 | 472 | cell = TableCell([]) |
paul@102 | 473 | self.parse_region_details(cell, self.table_row_pattern_names) |
paul@9 | 474 | |
paul@31 | 475 | # Handle the end of the row. |
paul@12 | 476 | |
paul@54 | 477 | if self.matching_pattern() == "tableend": |
paul@55 | 478 | trailing = self.match_group("extra") |
paul@2 | 479 | |
paul@31 | 480 | # If the cell was started but not finished, convert the row into text. |
paul@2 | 481 | |
paul@31 | 482 | if not row.nodes or not cell.empty(): |
paul@165 | 483 | |
paul@165 | 484 | # Convert the nodes back to text. |
paul@165 | 485 | |
paul@165 | 486 | serialiser = self.get_serialiser() |
paul@165 | 487 | |
paul@31 | 488 | for node in row.nodes: |
paul@165 | 489 | region.append_inline(Text(serialise(node, serialiser))) |
paul@165 | 490 | |
paul@165 | 491 | region.append_inline(Text(serialise(cell, serialiser) + trailing)) |
paul@17 | 492 | |
paul@43 | 493 | self.new_block(region) |
paul@31 | 494 | return |
paul@29 | 495 | |
paul@31 | 496 | # Append the final cell, if not empty. |
paul@29 | 497 | |
paul@31 | 498 | else: |
paul@31 | 499 | row.trailing = trailing |
paul@29 | 500 | |
paul@31 | 501 | if not cell.empty(): |
paul@31 | 502 | row.append(cell) |
paul@31 | 503 | break |
paul@24 | 504 | |
paul@31 | 505 | # A cell separator has been found. |
paul@24 | 506 | |
paul@31 | 507 | row.append(cell) |
paul@24 | 508 | |
paul@36 | 509 | # Add the row to the table and any new table to the region. |
paul@36 | 510 | |
paul@36 | 511 | table.add(row) |
paul@36 | 512 | if new_table: |
paul@43 | 513 | self.add_node(region, new_table) |
paul@36 | 514 | |
paul@43 | 515 | self.new_block(region) |
paul@24 | 516 | |
paul@37 | 517 | def parse_valign(self, attrs): |
paul@24 | 518 | |
paul@31 | 519 | "Handle vertical alignment within 'attrs'." |
paul@24 | 520 | |
paul@55 | 521 | value = self.match_group("value") |
paul@31 | 522 | attr = TableAttr("valign", value == "^" and "top" or "bottom", True) |
paul@31 | 523 | attrs.append(attr) |
paul@25 | 524 | |
paul@30 | 525 | |
paul@30 | 526 | |
paul@98 | 527 | def inline_patterns_for(self, name): |
paul@172 | 528 | |
paul@172 | 529 | "Return active patterns for the inline element having the given 'name'." |
paul@172 | 530 | |
paul@98 | 531 | names = self.inline_pattern_names[:] |
paul@98 | 532 | names[names.index(name)] = "%send" % name |
paul@98 | 533 | return names |
paul@98 | 534 | |
paul@98 | 535 | |
paul@98 | 536 | |
paul@31 | 537 | # Inline formatting handlers. |
paul@31 | 538 | |
paul@37 | 539 | def parse_inline(self, region, cls, pattern_name): |
paul@23 | 540 | |
paul@31 | 541 | "Handle an inline region." |
paul@31 | 542 | |
paul@31 | 543 | span = cls([]) |
paul@37 | 544 | self.parse_region_details(span, self.inline_patterns_for(pattern_name)) |
paul@31 | 545 | region.append_inline(span) |
paul@20 | 546 | |
paul@37 | 547 | def parse_larger(self, region): |
paul@37 | 548 | self.parse_inline(region, Larger, "larger") |
paul@31 | 549 | |
paul@37 | 550 | def parse_monospace(self, region): |
paul@64 | 551 | span = Monospace([]) |
paul@64 | 552 | self.parse_region_details(span, ["monospaceend"]) |
paul@64 | 553 | region.append_inline(span) |
paul@20 | 554 | |
paul@37 | 555 | def parse_smaller(self, region): |
paul@37 | 556 | self.parse_inline(region, Smaller, "smaller") |
paul@31 | 557 | |
paul@48 | 558 | def parse_strike(self, region): |
paul@48 | 559 | self.parse_inline(region, Strikethrough, "strike") |
paul@48 | 560 | |
paul@37 | 561 | def parse_sub(self, region): |
paul@37 | 562 | self.parse_inline(region, Subscript, "sub") |
paul@31 | 563 | |
paul@37 | 564 | def parse_super(self, region): |
paul@37 | 565 | self.parse_inline(region, Superscript, "super") |
paul@20 | 566 | |
paul@37 | 567 | def parse_underline(self, region): |
paul@37 | 568 | self.parse_inline(region, Underline, "underline") |
paul@31 | 569 | |
paul@167 | 570 | # Link formatting handlers. |
paul@167 | 571 | |
paul@167 | 572 | def _parse_link(self, region, cls, pattern_names): |
paul@167 | 573 | target = self.match_group("target") |
paul@167 | 574 | end = self.match_group("end") |
paul@167 | 575 | |
paul@222 | 576 | # Obtain an object for the link target. |
paul@222 | 577 | |
paul@222 | 578 | link_target = parse_link_target(target, self.metadata) |
paul@222 | 579 | |
paul@222 | 580 | # Obtain an object for the node. |
paul@222 | 581 | |
paul@222 | 582 | span = cls([], link_target) |
paul@167 | 583 | |
paul@167 | 584 | # Obtain the extra details. |
paul@167 | 585 | |
paul@167 | 586 | if not end: |
paul@167 | 587 | cls = LinkLabel |
paul@167 | 588 | |
paul@167 | 589 | # Introduce a label or parameter for each separated region. |
paul@167 | 590 | |
paul@167 | 591 | while True: |
paul@167 | 592 | param = cls([]) |
paul@167 | 593 | self.parse_region_details(param, pattern_names) |
paul@167 | 594 | span.append(param) |
paul@167 | 595 | |
paul@167 | 596 | if self.matching_pattern() != "linksep": |
paul@167 | 597 | break |
paul@167 | 598 | |
paul@167 | 599 | cls = LinkParameter |
paul@167 | 600 | |
paul@167 | 601 | region.append_inline(span) |
paul@167 | 602 | |
paul@222 | 603 | # Record the link target for later processing. |
paul@222 | 604 | |
paul@222 | 605 | self.root.link_targets.append(link_target) |
paul@222 | 606 | |
paul@167 | 607 | def parse_link(self, region): |
paul@167 | 608 | self._parse_link(region, Link, self.link_pattern_names) |
paul@167 | 609 | |
paul@167 | 610 | def parse_transclusion(self, region): |
paul@167 | 611 | self._parse_link(region, Transclusion, self.transclusion_pattern_names) |
paul@167 | 612 | |
paul@31 | 613 | |
paul@19 | 614 | |
paul@77 | 615 | # Complete inline pattern handlers. |
paul@77 | 616 | |
paul@116 | 617 | def parse_anchor(self, region): |
paul@116 | 618 | target = self.match_group("target") |
paul@116 | 619 | anchor = Anchor(target) |
paul@116 | 620 | region.append_inline(anchor) |
paul@116 | 621 | |
paul@106 | 622 | def parse_linebreak(self, region): |
paul@106 | 623 | region.append_inline(LineBreak()) |
paul@106 | 624 | |
paul@77 | 625 | def parse_macro(self, region): |
paul@77 | 626 | name = self.match_group("name") |
paul@77 | 627 | args = self.match_group("args") |
paul@77 | 628 | |
paul@77 | 629 | # Obtain the raw arguments. Moin usually leaves it to the macro to |
paul@77 | 630 | # interpret the individual arguments. |
paul@77 | 631 | |
paul@77 | 632 | arglist = args and args.split(",") or [] |
paul@162 | 633 | macro = Macro(name, arglist, region.append_point(), region) |
paul@77 | 634 | region.append_inline(macro) |
paul@77 | 635 | |
paul@87 | 636 | # Record the macro for later processing. |
paul@87 | 637 | |
paul@87 | 638 | self.root.macros.append(macro) |
paul@87 | 639 | |
paul@169 | 640 | def parse_verbatim(self, region): |
paul@169 | 641 | text = self.match_group("verbatim") |
paul@169 | 642 | region.append_inline(Verbatim(text)) |
paul@169 | 643 | |
paul@77 | 644 | |
paul@77 | 645 | |
paul@31 | 646 | # Table attribute handlers. |
paul@31 | 647 | |
paul@37 | 648 | def parse_table_attr(self, attrs, pattern_name): |
paul@31 | 649 | |
paul@31 | 650 | "Handle a table attribute." |
paul@25 | 651 | |
paul@55 | 652 | attrs.append(TableAttr(pattern_name, self.match_group("value"), True)) |
paul@37 | 653 | |
paul@37 | 654 | def parse_colour(self, cell): |
paul@205 | 655 | self.parse_table_attr(cell, "bgcolor") |
paul@37 | 656 | |
paul@37 | 657 | def parse_colspan(self, cell): |
paul@37 | 658 | self.parse_table_attr(cell, "colspan") |
paul@37 | 659 | |
paul@37 | 660 | def parse_rowspan(self, cell): |
paul@37 | 661 | self.parse_table_attr(cell, "rowspan") |
paul@37 | 662 | |
paul@37 | 663 | def parse_width(self, cell): |
paul@37 | 664 | self.parse_table_attr(cell, "width") |
paul@37 | 665 | |
paul@37 | 666 | |
paul@37 | 667 | |
paul@37 | 668 | # Regular expressions. |
paul@37 | 669 | |
paul@37 | 670 | syntax = { |
paul@37 | 671 | # Page regions: |
paul@55 | 672 | |
paul@55 | 673 | "regionstart" : join((group("indent", r"\N*"), # ws... (optional) |
paul@55 | 674 | group("level", repeat("[{]", 3)))), # {{{... |
paul@55 | 675 | |
paul@55 | 676 | "regionend" : join((r"\N*", # ws... (optional) |
paul@67 | 677 | group("feature", join(( |
paul@67 | 678 | group("level", repeat("[}]", 3)), # }}}... |
paul@151 | 679 | optional(group("extra", r"\n"))))))), # nl (optional) |
paul@151 | 680 | |
paul@151 | 681 | # Region header and directives: |
paul@55 | 682 | |
paul@55 | 683 | "header" : join(("#!", # #! |
paul@55 | 684 | group("args", ".*?"), "\n")), # text-excl-nl |
paul@25 | 685 | |
paul@151 | 686 | "directive" : join((r"^#", # # |
paul@151 | 687 | group("directive", r".*?$"), # rest of line |
paul@151 | 688 | optional(group("extra", r"\n")))), # nl (optional) |
paul@151 | 689 | |
paul@37 | 690 | # Region contents: |
paul@76 | 691 | |
paul@76 | 692 | # Line-oriented patterns support features which require their own |
paul@76 | 693 | # separate lines. |
paul@55 | 694 | |
paul@55 | 695 | "break" : r"^(\s*?)\n", # blank line |
paul@55 | 696 | |
paul@151 | 697 | "comment" : join((r"^##", # ## |
paul@151 | 698 | group("comment", r".*?$"), # rest of line |
paul@151 | 699 | optional(group("extra", r"\n")))), # nl (optional) |
paul@151 | 700 | |
paul@55 | 701 | "defterm" : join(("^", |
paul@55 | 702 | group("pad", r"\N+"), # ws... |
paul@55 | 703 | expect(".+?::"))), # text :: |
paul@55 | 704 | |
paul@55 | 705 | "defterm_empty" : join(("^", |
paul@55 | 706 | group("pad", r"\N+"), # ws... |
paul@122 | 707 | expect("::\s+"))), # :: ws... |
paul@55 | 708 | |
paul@55 | 709 | "heading" : join(("^", |
paul@55 | 710 | group("extra", r"\N*"), # ws... (optional) |
paul@55 | 711 | group("level", "=+"), # =... |
paul@55 | 712 | group("pad", r"\s+"), # ws... |
paul@55 | 713 | expect(join((r".*?\N+", # text |
paul@55 | 714 | recur("level"), # =... |
paul@55 | 715 | r"\N*$"))))), # ws... (optional) |
paul@55 | 716 | |
paul@55 | 717 | "listitem" : join(("^", |
paul@55 | 718 | group("indent", r"\N+"), # ws... |
paul@55 | 719 | group("marker", r"\*"), # list-marker |
paul@55 | 720 | group("pad", r"\s*"))), # ws... (optional) |
paul@55 | 721 | |
paul@55 | 722 | "listitem_num" : join(("^", |
paul@55 | 723 | group("indent", r"\N+"), # ws... |
paul@55 | 724 | group("marker", r"\d+\."), # decimal-marker |
paul@55 | 725 | optional(join(("#", group("num", r"\d+")))), # # num (optional) |
paul@55 | 726 | group("pad", r"\s+"))), # ws... |
paul@55 | 727 | |
paul@55 | 728 | "listitem_alpha": join(("^", |
paul@55 | 729 | group("indent", r"\N+"), # ws... |
paul@55 | 730 | group("marker", r"[aA]\."), # alpha-marker |
paul@55 | 731 | optional(join(("#", group("num", r"\d+")))), # # num (optional) |
paul@55 | 732 | group("pad", r"\s+"))), # ws... |
paul@55 | 733 | |
paul@55 | 734 | "listitem_roman": join(("^", |
paul@55 | 735 | group("indent", r"\N+"), # ws... |
paul@55 | 736 | group("marker", r"[iI]\."), # roman-marker |
paul@55 | 737 | optional(join(("#", group("num", r"\d+")))), # # num (optional) |
paul@55 | 738 | group("pad", r"\s+"))), # ws... |
paul@55 | 739 | |
paul@55 | 740 | "listitem_dot" : join(("^", |
paul@55 | 741 | group("indent", r"\N+"), # ws... |
paul@55 | 742 | group("marker", r"\."), # dot-marker |
paul@55 | 743 | group("pad", r"\s*"))), # ws... (optional) |
paul@55 | 744 | |
paul@55 | 745 | "tablerow" : r"^\|\|", # || |
paul@37 | 746 | |
paul@37 | 747 | # Region contents: |
paul@76 | 748 | |
paul@76 | 749 | # Inline patterns are for markup features that appear within blocks. |
paul@76 | 750 | # The patterns below start inline spans that can contain other markup |
paul@76 | 751 | # features. |
paul@55 | 752 | |
paul@55 | 753 | "fontstyle" : group("style", repeat("'", 2, 6)), # ''... |
paul@172 | 754 | |
paul@172 | 755 | # Trivial markup balancing is done below using the end features. |
paul@172 | 756 | |
paul@172 | 757 | "larger" : join((r"~\+", # ~+ |
paul@172 | 758 | expect(r"\P*?\+~"))), # ... +~ |
paul@172 | 759 | |
paul@172 | 760 | "monospace" : join((r"`", # ` |
paul@172 | 761 | expect(r"\P*?`"))), # ... ` |
paul@172 | 762 | |
paul@172 | 763 | "smaller" : join((r"~-", # ~- |
paul@172 | 764 | expect(r"\P*?-~"))), # ... -~ |
paul@172 | 765 | |
paul@172 | 766 | "strike" : join((r"--\(", # --( |
paul@172 | 767 | expect(r"\P*?\)--"))), # ... )-- |
paul@172 | 768 | |
paul@172 | 769 | "sub" : join((r",,", # ,, |
paul@172 | 770 | expect(r"\P*?,,"))), # ... ,, |
paul@172 | 771 | |
paul@172 | 772 | "super" : join((r"\^", # ^ |
paul@172 | 773 | expect(r"\P*?\^"))), # ... ^ |
paul@172 | 774 | |
paul@172 | 775 | "underline" : join((r"__", # __ |
paul@172 | 776 | expect(r"\P*?__"))), # ... __ |
paul@172 | 777 | |
paul@172 | 778 | # Rules are treated as inline but, unlike the above, appear without |
paul@172 | 779 | # contents. |
paul@172 | 780 | |
paul@55 | 781 | "rule" : group("rule", "-----*"), # ----... |
paul@25 | 782 | |
paul@167 | 783 | # Links and transclusions may start inline spans. |
paul@167 | 784 | |
paul@167 | 785 | "link" : join((r"\[\[", # [[ |
paul@192 | 786 | group("target", r"\E*?"), # ... |
paul@167 | 787 | choice((r"\|", # | |
paul@167 | 788 | group("end", r"]]"))))), # ]] |
paul@167 | 789 | |
paul@167 | 790 | "transclusion" : join((r"\{\{", # {{ |
paul@167 | 791 | excl(r"\{"), # not-{ |
paul@167 | 792 | group("target", ".*?"), # ... |
paul@167 | 793 | choice((r"\|", # | |
paul@167 | 794 | group("end", r"}}"))))), # }} |
paul@167 | 795 | |
paul@76 | 796 | # Complete inline patterns are for markup features that do not support |
paul@76 | 797 | # arbitrary content within them: |
paul@55 | 798 | |
paul@116 | 799 | "anchor" : join((r"\(\(", # (( |
paul@116 | 800 | group("target", ".*?"), # target |
paul@116 | 801 | r"\)\)")), # )) |
paul@116 | 802 | |
paul@106 | 803 | "linebreak" : r"\\\\", # \\ |
paul@106 | 804 | |
paul@77 | 805 | "macro" : join(("<<", # << |
paul@77 | 806 | group("name", "\w+?"), # digit-letter... |
paul@77 | 807 | optional(join((r"\(", # ( (optional) |
paul@77 | 808 | group("args", ".*?"), # not-)... |
paul@77 | 809 | r"\)"))), # ) (optional) |
paul@77 | 810 | ">>")), # >> |
paul@77 | 811 | |
paul@169 | 812 | "verbatim" : join(("<<<", # <<< |
paul@169 | 813 | group("verbatim", ".*?"), # ... |
paul@169 | 814 | ">>>")), |
paul@169 | 815 | |
paul@76 | 816 | # Ending patterns for inline features: |
paul@55 | 817 | |
paul@55 | 818 | "largerend" : r"\+~", # +~ |
paul@167 | 819 | "linkend" : r"]]", # ]] |
paul@55 | 820 | "monospaceend" : r"`", # ` |
paul@55 | 821 | "smallerend" : r"-~", # -~ |
paul@55 | 822 | "strikeend" : r"\)--", # )-- |
paul@55 | 823 | "subend" : r",,", # ,, |
paul@55 | 824 | "superend" : r"\^", # ^ |
paul@167 | 825 | "transclusionend": r"}}", # }} |
paul@55 | 826 | "underlineend" : r"__", # __ |
paul@37 | 827 | |
paul@37 | 828 | # Heading contents: |
paul@55 | 829 | |
paul@55 | 830 | "headingend" : join((group("pad", r"\N+"), # ws... |
paul@55 | 831 | group("level", "=+"), # =... |
paul@63 | 832 | group("extra", r"\N*\n"))), # ws (optional) nl |
paul@37 | 833 | |
paul@167 | 834 | # Link/transclusion contents: |
paul@167 | 835 | |
paul@167 | 836 | "linksep" : r"\|", # | |
paul@167 | 837 | |
paul@37 | 838 | # List contents: |
paul@55 | 839 | |
paul@55 | 840 | "deftermend" : join(("::", group("pad", r"\s*?\n"))), # :: |
paul@55 | 841 | # ws... (optional) |
paul@55 | 842 | # nl |
paul@55 | 843 | |
paul@55 | 844 | "deftermsep" : join(("::", group("pad", r"\s+"))), # :: |
paul@122 | 845 | # ws... |
paul@55 | 846 | |
paul@122 | 847 | "listitemend" : join((r"^", # next line |
paul@148 | 848 | choice((expect(r"[^\s]"), # without indent |
paul@148 | 849 | expect(r"\Z"), # end of string |
paul@122 | 850 | expect(r"\N+\*"), # or with ws... list-marker |
paul@122 | 851 | expect(r"\N+\d\."), # or with ws... decimal-marker |
paul@122 | 852 | expect(r"\N+[aA]\."), # or with ws... alpha-marker |
paul@122 | 853 | expect(r"\N+[iI]\."), # or with ws... roman-marker |
paul@122 | 854 | expect(r"\N+\."), # or with ws... dot-marker |
paul@122 | 855 | expect(r"\N+.+?::\s"), # or with ws... text :: ws (next defterm) |
paul@122 | 856 | expect(r"\N+::\s"))))), # or with ws... :: ws (next defitem) |
paul@37 | 857 | |
paul@37 | 858 | # Table contents: |
paul@55 | 859 | |
paul@107 | 860 | "tableattrs" : join(("<", # lt |
paul@107 | 861 | excl("<"))), # not-lt |
paul@107 | 862 | |
paul@55 | 863 | "tablecell" : r"\|\|", # || |
paul@55 | 864 | |
paul@55 | 865 | "tableend" : join((group("extra", r"\s*?"), # ws... (optional) |
paul@55 | 866 | "^")), # next line |
paul@25 | 867 | |
paul@37 | 868 | # Table attributes: |
paul@55 | 869 | |
paul@55 | 870 | "tableattrsend" : r">", # > |
paul@55 | 871 | "halign" : group("value", "[(:)]"), # halign-marker |
paul@55 | 872 | "valign" : group("value", "[v^]"), # valign-marker |
paul@55 | 873 | "colour" : group("value", join(("\#", # # |
paul@205 | 874 | repeat("[0-9A-Fa-f]", 6, 6)))), # nnnnnn |
paul@55 | 875 | |
paul@55 | 876 | "colspan" : join(("-", # - |
paul@55 | 877 | group("value", "\d+"))), # n... |
paul@55 | 878 | |
paul@55 | 879 | "rowspan" : join((r"\|", # | |
paul@55 | 880 | group("value", "\d+"))), # n... |
paul@55 | 881 | |
paul@55 | 882 | "width" : group("value", "\d+%"), # n... % |
paul@55 | 883 | |
paul@55 | 884 | "attrname" : join((excl(r"[-\d]"), # not-dash-or-digit |
paul@55 | 885 | group("name", r"[-\w]+"))), # dash-digit-letter... |
paul@55 | 886 | |
paul@55 | 887 | "attrvalue" : join(("=", group("quote", r"\Q"), # quote |
paul@55 | 888 | group("value", ".*?"), # non-quote... (optional) |
paul@55 | 889 | recur("quote"))), # quote |
paul@37 | 890 | } |
paul@37 | 891 | |
paul@37 | 892 | patterns = get_patterns(syntax) |
paul@37 | 893 | |
paul@37 | 894 | |
paul@37 | 895 | |
paul@76 | 896 | # Patterns available within certain markup features. |
paul@31 | 897 | |
paul@102 | 898 | table_attr_pattern_names = [ |
paul@37 | 899 | "attrname", "colour", "colspan", "halign", "rowspan", "tableattrsend", |
paul@37 | 900 | "valign", "width" |
paul@37 | 901 | ] |
paul@37 | 902 | |
paul@167 | 903 | inline_without_links_pattern_names = [ |
paul@167 | 904 | "anchor", "fontstyle", "larger", "linebreak", "macro", |
paul@116 | 905 | "monospace", "regionstart", "smaller", "strike", "sub", "super", |
paul@169 | 906 | "underline", "verbatim" |
paul@37 | 907 | ] |
paul@37 | 908 | |
paul@167 | 909 | inline_pattern_names = inline_without_links_pattern_names + [ |
paul@167 | 910 | "link", "transclusion"] |
paul@167 | 911 | |
paul@167 | 912 | link_pattern_names = inline_without_links_pattern_names + [ |
paul@167 | 913 | "linkend", "linksep", "transclusion"] |
paul@167 | 914 | |
paul@43 | 915 | list_pattern_names = [ |
paul@43 | 916 | "listitem", "listitem_alpha", "listitem_dot", "listitem_num", |
paul@43 | 917 | "listitem_roman", |
paul@43 | 918 | ] |
paul@43 | 919 | |
paul@37 | 920 | listitem_pattern_names = inline_pattern_names + ["listitemend"] |
paul@37 | 921 | |
paul@57 | 922 | region_without_table_pattern_names = inline_pattern_names + list_pattern_names + [ |
paul@151 | 923 | "break", "comment", "heading", "defterm", "defterm_empty", |
paul@57 | 924 | "regionend", "rule", |
paul@37 | 925 | ] |
paul@37 | 926 | |
paul@102 | 927 | table_row_pattern_names = inline_pattern_names + [ |
paul@37 | 928 | "tableattrs", "tablecell", "tableend" |
paul@37 | 929 | ] |
paul@37 | 930 | |
paul@167 | 931 | transclusion_pattern_names = inline_without_links_pattern_names + [ |
paul@167 | 932 | "linksep", "transclusionend"] |
paul@167 | 933 | |
paul@98 | 934 | # The region pattern names are specifically used by the common parser |
paul@98 | 935 | # functionality. |
paul@98 | 936 | |
paul@98 | 937 | region_pattern_names = region_without_table_pattern_names + ["tablerow"] |
paul@25 | 938 | |
paul@30 | 939 | |
paul@30 | 940 | |
paul@32 | 941 | # Pattern handlers. |
paul@31 | 942 | |
paul@32 | 943 | end_region = ParserBase.end_region |
paul@98 | 944 | parse_section_end = ParserBase.parse_region_end |
paul@31 | 945 | |
paul@31 | 946 | handlers = { |
paul@31 | 947 | None : end_region, |
paul@116 | 948 | "anchor" : parse_anchor, |
paul@31 | 949 | "attrname" : parse_attrname, |
paul@31 | 950 | "break" : parse_break, |
paul@31 | 951 | "colour" : parse_colour, |
paul@31 | 952 | "colspan" : parse_colspan, |
paul@151 | 953 | "comment" : parse_comment, |
paul@31 | 954 | "defterm" : parse_defterm, |
paul@31 | 955 | "defterm_empty" : parse_defterm_empty, |
paul@31 | 956 | "deftermend" : end_region, |
paul@31 | 957 | "deftermsep" : end_region, |
paul@151 | 958 | "directive" : parse_directive, |
paul@31 | 959 | "fontstyle" : parse_fontstyle, |
paul@31 | 960 | "halign" : parse_halign, |
paul@31 | 961 | "heading" : parse_heading, |
paul@31 | 962 | "headingend" : parse_heading_end, |
paul@31 | 963 | "larger" : parse_larger, |
paul@31 | 964 | "largerend" : end_region, |
paul@106 | 965 | "linebreak" : parse_linebreak, |
paul@47 | 966 | "link" : parse_link, |
paul@167 | 967 | "linkend" : end_region, |
paul@167 | 968 | "linksep" : end_region, |
paul@77 | 969 | "macro" : parse_macro, |
paul@31 | 970 | "listitemend" : end_region, |
paul@31 | 971 | "listitem" : parse_listitem, |
paul@31 | 972 | "listitem_alpha" : parse_listitem, |
paul@31 | 973 | "listitem_dot" : parse_listitem, |
paul@31 | 974 | "listitem_num" : parse_listitem, |
paul@31 | 975 | "listitem_roman" : parse_listitem, |
paul@31 | 976 | "monospace" : parse_monospace, |
paul@31 | 977 | "monospaceend" : end_region, |
paul@31 | 978 | "regionstart" : parse_section, |
paul@31 | 979 | "regionend" : parse_section_end, |
paul@31 | 980 | "rowspan" : parse_rowspan, |
paul@31 | 981 | "rule" : parse_rule, |
paul@31 | 982 | "smaller" : parse_smaller, |
paul@31 | 983 | "smallerend" : end_region, |
paul@48 | 984 | "strike" : parse_strike, |
paul@48 | 985 | "strikeend" : end_region, |
paul@31 | 986 | "sub" : parse_sub, |
paul@31 | 987 | "subend" : end_region, |
paul@31 | 988 | "super" : parse_super, |
paul@31 | 989 | "superend" : end_region, |
paul@31 | 990 | "tableattrs" : parse_table_attrs, |
paul@31 | 991 | "tableattrsend" : end_region, |
paul@31 | 992 | "tablerow" : parse_table_row, |
paul@31 | 993 | "tablecell" : end_region, |
paul@31 | 994 | "tableend" : end_region, |
paul@167 | 995 | "transclusion" : parse_transclusion, |
paul@167 | 996 | "transclusionend" : end_region, |
paul@31 | 997 | "underline" : parse_underline, |
paul@31 | 998 | "underlineend" : end_region, |
paul@31 | 999 | "valign" : parse_valign, |
paul@169 | 1000 | "verbatim" : parse_verbatim, |
paul@31 | 1001 | "width" : parse_width, |
paul@31 | 1002 | } |
paul@2 | 1003 | |
paul@42 | 1004 | parser = MoinParser |
paul@0 | 1005 | |
paul@0 | 1006 | # vim: tabstop=4 expandtab shiftwidth=4 |