# HG changeset patch # User Paul Boddie # Date 1369839737 -7200 # Node ID b716feccdeba51627c1497a4740082557b4d1029 # Parent 0da044296fe2e186d68a0feba80fd2b1a14c9ce3 Fixed newlines in preformatted regions. Added a note about Confluence markup translation and region nesting. diff -r 0da044296fe2 -r b716feccdeba TO_DO.txt --- a/TO_DO.txt Wed May 29 15:30:10 2013 +0200 +++ b/TO_DO.txt Wed May 29 17:02:17 2013 +0200 @@ -1,17 +1,12 @@ -DEV/Google Summer of Code 2013 (15564903) - -
in preformatted regions should be converted to newlines - DEV/A 5 Minute Guide to Get the Mailman Web UI Running (only for development) (13303877) Preformatted regions on their own line might be converted into proper sections This affects both markup types -DEV/MailmanOnLaunchpad (589838) +DEV/MailmanOnLaunchpad (14352425) - (Preformatted regions are not being formatted - The previous version (15958128) had a newline at the start of the CDATA section and thus avoided this problem - The problem is that preformatted regions containing newlines require a newline immediately after {{{ to be recognised) + Confluence parsing output does not nest Moin regions and thus handle + preformatted text inside regions DEV/GSoC 2011 - Conversion from Confluence wiki to Moin (11960378) diff -r 0da044296fe2 -r b716feccdeba wikiparser.py --- a/wikiparser.py Wed May 29 15:30:10 2013 +0200 +++ b/wikiparser.py Wed May 29 17:02:17 2013 +0200 @@ -218,6 +218,14 @@ (r"\~", "~"), ] +preformatted_notation_mapping = [ + (r"\!", "!"), + (r"\-", "-"), + (r"\\""\n", "\n"), + (r"\\ ", "\n"), + (r"\~", "~"), + ] + # Translation helpers. markers = { @@ -345,11 +353,11 @@ else: return translate_text(match.group()) -def translate_text(s): +def translate_text(s, preformatted=False): "Translate the plain text string 's', converting notation." - for before, after in notation_mapping: + for before, after in preformatted and preformatted_notation_mapping or notation_mapping: s = s.replace(before, after) return s @@ -362,11 +370,12 @@ """ parts = [] + preformatted = sectiontype in preformatted_sectiontypes last = 0 for match in content_regexp.finditer(text): start, end = match.span() - parts.append(translate_text(text[last:start])) + parts.append(translate_text(text[last:start], preformatted)) # Handle unformatted sections. @@ -377,7 +386,7 @@ last = end - parts.append(translate_text(text[last:])) + parts.append(translate_text(text[last:], preformatted)) return "".join(parts) def translate_block(blocktype, blocktext): @@ -462,6 +471,8 @@ "warning" : "#!wiki warning\n", } +preformatted_sectiontypes = (None, "noformat") + macrotypes = { "anchor" : "<>", "color" : "<>", diff -r 0da044296fe2 -r b716feccdeba xmlparser.py --- a/xmlparser.py Wed May 29 15:30:10 2013 +0200 +++ b/xmlparser.py Wed May 29 17:02:17 2013 +0200 @@ -69,6 +69,11 @@ "br" : "<
>", } +simple_preformatted_tags = { + # XHTML tag MoinMoin syntax + "br" : "\n", + } + list_tags = { # XHTML list tag MoinMoin list item syntax "ol" : "1. %s", @@ -369,8 +374,10 @@ elif text and conversion: text = conversion % text - elif simple_tags.has_key(name): + elif simple_tags.has_key(name) and not self.is_preformatted(): text = simple_tags[name] + elif simple_preformatted_tags.has_key(name) and self.is_preformatted(): + text = simple_preformatted_tags[name]