changeset 195:d75075769daa

macro converter: use Type class to check for mimetype match and getting name param value, fixes #22
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 28 Apr 2011 13:18:10 +0200
parents 389cd14f0888
children 1b3dec65779e
files MoinMoin/converter/macro.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/macro.py	Tue Apr 26 00:21:06 2011 +0200
+++ b/MoinMoin/converter/macro.py	Thu Apr 28 13:18:10 2011 +0200
@@ -20,7 +20,7 @@
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.converter._args import Arguments
 from MoinMoin.util import iri
-from MoinMoin.util.mime import type_moin_document
+from MoinMoin.util.mime import type_moin_document, Type
 from MoinMoin.util.tree import html, moin_page
 
 
@@ -34,10 +34,14 @@
         type = elem.get(moin_page.content_type)
         alt = elem.get(moin_page.alt)
 
-        # TODO
-        if not type or not type.startswith('x-moin/macro;name='):
+        if not type:
             return
-        name = type[18:]
+
+        type = Type(type)
+        if not (type.type == 'x-moin' and type.subtype == 'macro'):
+            return
+
+        name = type.parameters['name']
 
         context_block = elem.tag == moin_page.part