changeset 2648:b27a0c43dad0

merged
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 03 Jul 2014 22:01:38 +0200
parents 85b9375a12c8 (current diff) 85cd88affe5a (diff)
children bc0f43fecbc7
files
diffstat 8 files changed, 68 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/_tests/test_mediawiki_in.py	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/converter/_tests/test_mediawiki_in.py	Thu Jul 03 22:01:38 2014 +0200
@@ -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	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/converter/html_out.py	Thu Jul 03 22:01:38 2014 +0200
@@ -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	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/converter/mediawiki_in.py	Thu Jul 03 22:01:38 2014 +0200
@@ -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:
--- a/MoinMoin/forms.py	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/forms.py	Thu Jul 03 22:01:38 2014 +0200
@@ -245,7 +245,7 @@
                     name_ = item.meta['name'][0]
                 except IndexError:
                     name_ = "This item doesn't exist"
-                value = "{0} ({1})".format(value, name_)
+                value = u"{0} ({1})".format(value, name_)
             else:
                 value = child.u
             subscriptions.append(value)
--- a/MoinMoin/user.py	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/user.py	Thu Jul 03 22:01:38 2014 +0200
@@ -209,14 +209,14 @@
     :return: subscription string
     """
     if keyword == ITEMID:
-        subscription = "{0}:{1}".format(ITEMID, value)
+        subscription = u"{0}:{1}".format(ITEMID, value)
     elif keyword in [NAME, TAGS, NAMERE, NAMEPREFIX, ]:
         if namespace is not None:
-            subscription = "{0}:{1}:{2}".format(keyword, namespace, value)
+            subscription = u"{0}:{1}:{2}".format(keyword, namespace, value)
         else:
-            raise ValueError("The subscription by {0} keyword requires a namespace".format(keyword))
+            raise ValueError(u"The subscription by {0} keyword requires a namespace".format(keyword))
     else:
-        raise ValueError("Invalid keyword string: {0}".format(keyword))
+        raise ValueError(u"Invalid keyword string: {0}".format(keyword))
     return subscription
 
 
@@ -349,7 +349,7 @@
         name = getattr(self, NAME, [])
         itemid = getattr(self, ITEMID, None)
 
-        return "<{0}.{1} at {2:#x} name:{3!r} itemid:{4!r} valid:{5!r} trusted:{6!r}>".format(
+        return u"<{0}.{1} at {2:#x} name:{3!r} itemid:{4!r} valid:{5!r} trusted:{6!r}>".format(
             self.__class__.__module__, self.__class__.__name__, id(self),
             name, itemid, self.valid, self.trusted)
 
@@ -585,10 +585,10 @@
         subscriptions = set()
         itemid = meta.get(ITEMID)
         if itemid is not None:
-            subscriptions.update(["{0}:{1}".format(ITEMID, itemid)])
-        subscriptions.update("{0}:{1}:{2}".format(NAME, item_namespace, name)
+            subscriptions.update([u"{0}:{1}".format(ITEMID, itemid)])
+        subscriptions.update(u"{0}:{1}:{2}".format(NAME, item_namespace, name)
                              for name in meta.get(NAME, []))
-        subscriptions.update("{0}:{1}:{2}".format(TAGS, item_namespace, tag)
+        subscriptions.update(u"{0}:{1}:{2}".format(TAGS, item_namespace, tag)
                              for tag in meta.get(TAGS, []))
         if subscriptions & set(self.subscriptions):
             return True
--- a/MoinMoin/util/subscriptions.py	Thu Jul 03 22:00:12 2014 +0200
+++ b/MoinMoin/util/subscriptions.py	Thu Jul 03 22:01:38 2014 +0200
@@ -37,13 +37,13 @@
     tags = meta.get(TAGS)
     terms = []
     if itemid is not None:
-        terms.extend([Term(SUBSCRIPTION_IDS, "{0}:{1}".format(ITEMID, itemid))])
+        terms.extend([Term(SUBSCRIPTION_IDS, u"{0}:{1}".format(ITEMID, itemid))])
     if namespace is not None:
         if name is not None:
-            terms.extend(Term(SUBSCRIPTION_IDS, "{0}:{1}:{2}".format(NAME, namespace, name_))
+            terms.extend(Term(SUBSCRIPTION_IDS, u"{0}:{1}:{2}".format(NAME, namespace, name_))
                          for name_ in name)
         if tags is not None:
-            terms.extend(Term(SUBSCRIPTION_IDS, "{0}:{1}:{2}".format(TAGS, namespace, tag))
+            terms.extend(Term(SUBSCRIPTION_IDS, u"{0}:{1}:{2}".format(TAGS, namespace, tag))
                          for tag in tags)
     query = Or(terms)
     with flaskg.storage.indexer.ix[LATEST_REVS].searcher() as searcher:
@@ -86,7 +86,7 @@
                     try:
                         pattern = re.compile(pattern, re.U)
                     except re.error:
-                        logging.error("Subscription pattern '{0}' has failed compilation.".format(pattern))
+                        logging.error(u"Subscription pattern '{0}' has failed compilation.".format(pattern))
                         continue
                     if any(pattern.search(name) for name in item_names):
                         matched_subscriptions.append(subscription)
Binary file contrib/serialized/items.moin has changed
--- a/setup.py	Thu Jul 03 22:00:12 2014 +0200
+++ b/setup.py	Thu Jul 03 22:01:38 2014 +0200
@@ -104,7 +104,7 @@
         'passlib>=1.6.0',  # strong password hashing (1.6 needed for consteq)
         'XStatic>=0.0.2',  # support for static file pypi packages
         'XStatic-Bootstrap==3.1.1.2',
-        'XStatic-Font-Awesome>=3.2.1.1',
+        'XStatic-Font-Awesome==3.2.1.1',  # see issue #443
         'XStatic-CKEditor>=3.6.1.2',
         'XStatic-autosize',
         'XStatic-jQuery>=1.8.2',