changeset 2645:73106ad93096

merge
author RogerHaase <haaserd@gmail.com>
date Sun, 29 Jun 2014 09:15:45 -0700
parents 80be9ab7c2ad (current diff) eb7e3ca48b21 (diff)
children f66dbed19e66
files
diffstat 3 files changed, 54 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/_tests/test_mediawiki_in.py	Sun Jun 29 09:13:14 2014 -0700
+++ b/MoinMoin/converter/_tests/test_mediawiki_in.py	Sun Jun 29 09:15:45 2014 -0700
@@ -33,8 +33,10 @@
             (u"'''''bold and italic'''''", u'<page><body><p><strong><emphasis>bold and italic</emphasis></strong></p></body></page>'),
             (u"<nowiki>no ''markup''</nowiki>\n\n<code>no ''markup''</code>\n\n<tt>no ''markup''</tt>", "<page><body><p><code>no ''markup''</code></p><p><code>no ''markup''</code></p><p><code>no ''markup''</code></p></body></page>"),
             (u"<pre>no ''markup'' block</pre>", u"<page><body><p><blockcode>no ''markup'' block</blockcode></p></body></page>"),
-            (u'<u>underscore</u>', u'<page><body><p><span text-decoration="underline">underscore</span></p></body></page>'),
-            (u'<del>Strikethrough</del>', u'<page><body><p><span text-decoration="line-through">Strikethrough</span></p></body></page>'),
+            (u'<u>underlined</u>', u'<page><body><p><u>underlined</u></p></body></page>'),
+            (u'<ins>inserted</ins>', u'<page><body><p><ins>inserted</ins></p></body></page>'),
+            (u'<del>Strikethrough</del>', u'<page><body><p><del>Strikethrough</del></p></body></page>'),
+            (u'<s>Strikethrough</s>', u'<page><body><p><s>Strikethrough</s></p></body></page>'),
             (u"test <sup>super</sup> or <sub>sub</sub>", u'<page><body><p>test <span baseline-shift="super">super</span> or <span baseline-shift="sub">sub</span></p></body></page>'),
             (u"text <blockquote> quote quote quote quote quote quote </blockquote> text", u"<page><body><p>text <blockquote> quote quote quote quote quote quote </blockquote> text</p></body></page>"),
             (u"aaa<br />bbb", u"<page><body><p>aaa<line-break />bbb</p></body></page>"),
--- a/MoinMoin/converter/html_out.py	Sun Jun 29 09:13:14 2014 -0700
+++ b/MoinMoin/converter/html_out.py	Sun Jun 29 09:15:45 2014 -0700
@@ -233,6 +233,9 @@
     def visit_moinpage_code(self, elem):
         return self.new_copy(html.code, elem)
 
+    def visit_moinpage_del(self, elem):
+        return self.new_copy(html.del_, elem)
+
     def visit_moinpage_div(self, elem):
         return self.new_copy(html.div, elem)
 
@@ -281,6 +284,9 @@
 
         return html.span()
 
+    def visit_moinpage_ins(self, elem):
+        return self.new_copy(html.ins, elem)
+
     def visit_moinpage_line_break(self, elem):
         # TODO: attributes?
         return html.br()
@@ -529,6 +535,9 @@
         # If no any attributes is handled by our converter, just return span
         return self.new_copy(html.span, elem)
 
+    def visit_moinpage_s(self, elem):
+        return self.new_copy(html.s, elem)
+
     def visit_moinpage_strong(self, elem):
         return self.new_copy(html.strong, elem)
 
@@ -557,6 +566,9 @@
     def visit_moinpage_table_row(self, elem):
         return self.new_copy(html.tr, elem)
 
+    def visit_moinpage_u(self, elem):
+        return self.new_copy(html.u, elem)
+
 
 class SpecialId(object):
     def __init__(self):
--- a/MoinMoin/converter/mediawiki_in.py	Sun Jun 29 09:13:14 2014 -0700
+++ b/MoinMoin/converter/mediawiki_in.py	Sun Jun 29 09:15:45 2014 -0700
@@ -13,6 +13,7 @@
 from __future__ import absolute_import, division
 
 import re
+from htmlentitydefs import name2codepoint
 
 from werkzeug import url_encode
 
@@ -25,7 +26,6 @@
 from MoinMoin.util.tree import html, moin_page, xlink
 
 from ._args import Arguments
-from ._args_wiki import parse as parse_arguments
 from ._wiki_macro import ConverterMacro
 from ._util import decode_data, normalize_split_text, _Iter, _Stack
 
@@ -99,16 +99,6 @@
 
         return root
 
-    block_comment = r"""
-        (?P<comment>
-            ^ \#\#
-        )
-    """
-
-    def block_comment_repl(self, _iter_content, stack, comment):
-        # A comment also ends anything
-        stack.clear()
-
     block_head = r"""
         (?P<head>
             ^
@@ -448,7 +438,6 @@
                 c = int(entity[2:-1], 10)
             c = unichr(c)
         else:
-            from htmlentitydefs import name2codepoint
             c = unichr(name2codepoint.get(entity[1:-1], 0xfffe))
         stack.top_append(c)
 
@@ -494,25 +483,30 @@
 
     inline_strike = r"""
         (?P<strike>
-           (?P<strike_begin>
-           \<del\>
-           |
            \<s\>
-           )
-           |
-           (?P<strike_end>
-           \<\/del\>
            |
            \<\/s\>
-           )
         )
     """
 
-    def inline_strike_repl(self, stack, strike, strike_begin=None, strike_end=None):
-        if strike_begin is not None:
-            attrib = {moin_page.text_decoration: 'line-through'}
-            stack.push(moin_page.span(attrib=attrib))
-        elif strike_end is not None:
+    def inline_strike_repl(self, stack, strike):
+        if not stack.top_check('s'):
+            stack.push(moin_page.s())
+        else:
+            stack.pop()
+
+    inline_delete = r"""
+        (?P<delete>
+           \<del\>
+           |
+           \<\/del\>
+        )
+    """
+
+    def inline_delete_repl(self, stack, delete):
+        if not stack.top_check('del'):
+            stack.push(moin_page.del_())
+        else:
             stack.pop()
 
     inline_subscript = r"""
@@ -550,9 +544,22 @@
     """
 
     def inline_underline_repl(self, stack, underline):
-        if not stack.top_check('span'):
-            attrib = {moin_page.text_decoration: 'underline'}
-            stack.push(moin_page.span(attrib=attrib))
+        if not stack.top_check('u'):
+            stack.push(moin_page.u())
+        else:
+            stack.pop()
+
+    inline_insert = r"""
+        (?P<insert>
+            \<ins\>
+            |
+            \<\/ins\>
+        )
+    """
+
+    def inline_insert_repl(self, stack, insert):
+        if not stack.top_check('ins'):
+            stack.push(moin_page.ins())
         else:
             stack.pop()
 
@@ -763,7 +770,6 @@
     block = (
         block_line,
         block_table,
-        block_comment,
         block_head,
         block_separator,
         # block_macro,
@@ -786,9 +792,11 @@
         inline_footnote,
         # inline_size,
         inline_strike,
+        inline_delete,
         inline_subscript,
         inline_superscript,
         inline_underline,
+        inline_insert,
         inline_entity,
     )
     inline_re = re.compile('|'.join(inline), re.X | re.U)
@@ -885,6 +893,7 @@
                 if pre_text:
                     if len(tags):
                         tags[-1].text.append(pre_text)
+                        post_line = []
                     else:
                         post_line = [pre_text]
                 else: