The parse_googlemap function now uses the new XML tag parsing function.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 8 Sep 2013 21:24:04 +0000 (21:24 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 8 Sep 2013 21:24:04 +0000 (21:24 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@1542 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrpylib/mwmarkup.py

index f377c822287a227da9b27e22fd82c12615bc03b7..beffbd26b8c9ea03ee8f8469f1a4fba4f0e675cc 100644 (file)
@@ -201,13 +201,10 @@ def parse_googlemap(wikitext, detail=False):
         if not match is None: return (float(match.group(2)), float(match.group(1)), None, None)
         return RuntimeError(u'Could not parse line ' + line)
 
-    regexp = re.compile(u"(<googlemap[^>]*>)(.*?)(</googlemap>)", re.DOTALL)
-    match = regexp.search(wikitext)
-    if match is None: return None
-    start = match.start()
-    end = match.end()
-    content = match.group(2)
-    gm = xml.etree.ElementTree.XML((match.group(1)+match.group(3)).encode('UTF8'))
+    start, content, endtag, end = find_tag(wikitext, 'googlemap')
+    if content is None:
+        return None
+    gm = xml.etree.ElementTree.XML((wikitext[start:content]+wikitext[endtag:end]).encode('UTF8'))
     zoom = gm.get('zoom')
     lon = gm.get('lon')
     lat = gm.get('lat')
@@ -218,7 +215,7 @@ def parse_googlemap(wikitext, detail=False):
 
     coords = []
     paths = []
-    lines = content.split("\n")
+    lines = wikitext[content:endtag].split("\n")
     i = 0
     while i < len(lines):
         line = lines[i].strip()