Merge commit 'giskard/master'
[geekigeeki.git] / geekigeeki.py
index 54802f40e31930c1840b48461f297835b95d9053..494118661918794e5726000858eabe9db891023d 100755 (executable)
@@ -25,7 +25,7 @@ video_ext = "ogg|ogv|oga" # Not supported by Firefox 3.5: mkv|mpg|mpeg|mp4|avi|a
 image_re = re.compile(r".*\.(" + image_ext + "|" +  video_ext + ")$", re.IGNORECASE)
 video_re = re.compile(r".*\.(" + video_ext + ")$", re.IGNORECASE)
 # FIXME: we accept stuff like foo/../bar and we shouldn't
-file_re  = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)$")
+file_re  = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/ ]*)$")
 url_re   = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S$")
 ext_re   = re.compile(r"\.([^\./]+)$")
 
@@ -556,8 +556,8 @@ class WikiFormatter:
             | (?P<glyph> --)
 
             # Links
-            | (?P<macro> \<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>)
-            | (?P<hurl>  \[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])
+            | (?P<macro> \<\<[^\>]+\>\>)
+            | (?P<hurl>  \[\[[^\]]+\]\])
 
             # Inline HTML
             | (?P<html>             <(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])\b )
@@ -573,7 +573,7 @@ class WikiFormatter:
             # Lists, divs, spans and inline objects
             | (?P<li>    ^\s+[\*\#]\s+)
             | (?P<pre>   \{\{\{|\s*\}\}\})
-            | (?P<inl>   \{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})
+            | (?P<inl>   \{\{[^\}]+\}\})
 
             # Tables
             | (?P<tr>    ^\s*\|\|(=|)\s*)
@@ -667,16 +667,17 @@ class Page:
             pathname = (pathname and pathname + '/' ) + dirname
             out += '[[' + pathname + '|' + dirname + ']]/'
         out += ' ==\n'
+        images_out = '\n'
  
         for filename in page_list(self._filename(), file_re):
             if image_re.match(filename):
                 maxwidth = config_get('image_maxwidth', '400')
                 if maxwidth:
                     maxwidth = ' | maxwidth=' + str(maxwidth)
-                out += '{{' + self.page_name + '/' + filename + ' | ' + humanlink(filename) + maxwidth + ' | class=thumbleft}}\n'
+                images_out += '{{' + self.page_name + '/' + filename + ' | ' + humanlink(filename) + maxwidth + ' | class=thumbleft}}\n'
             else:
                 out += ' * [[' + self.page_name + '/' + filename + ']]\n'
-        return out
+        return out + images_out
 
     def pragmas(self):
         if not '_pragmas' in self.__dict__: