From: Bernie Innocenti Date: Wed, 8 Apr 2009 19:40:47 +0000 (+0200) Subject: Allow expanding wiki syntax within html tags X-Git-Tag: v4.0~9^2~15 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=042882ca5918a6f84a176e4ef9dc19428ac4566f;p=geekigeeki.git Allow expanding wiki syntax within html tags --- diff --git a/geekigeeki.py b/geekigeeki.py index 106250b..4450aea 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -37,12 +37,17 @@ link_re = re.compile("(?:\[\[|{{)([^\s\|]+)(?:\s*\|\s*([^\]]+)|)(?:\]\]|}})") title_done = False - # CGI stuff --------------------------------------------------------- - def script_name(): return os.environ.get('SCRIPT_NAME', '') +def query_string(): + path_info = os.environ.get('PATH_INFO', '') + if len(path_info) and path_info[0] == '/': + return path_info[1:] or 'FrontPage' + else: + return os.environ.get('QUERY_STRING', '') or 'FrontPage' + def privileged_path(): return privileged_url or script_name() @@ -365,7 +370,10 @@ class WikiFormatter: if macro: return macro(argv) else: - return '<<' + '|'.join(argv) + '>>' + msg = '<<' + '|'.join(argv) + '>>' + if not self.in_html: + msg = '' + msg + '' + return msg def _hurl_repl(self, word): m = link_re.match(word) @@ -407,10 +415,13 @@ class WikiFormatter: self.in_html += 1 return word; # Pass through + def _htmle_repl(self, word): + self.in_html -= 1 + return word; # Pass through + def _ent_repl(self, s): - if self.in_html and s == '>': - self.in_html -= 1 - return '>' + if self.in_html: + return s; # Pass through return {'&': '&', '<': '<', '>': '>'}[s] @@ -496,15 +507,16 @@ class WikiFormatter: | (?P \={2,6}) | (?P
\\\\) | (?P ^-{3,}) - | (?P \b(FIXME|TODO|DONE)\b) + | (?P \b( FIXME | TODO | DONE )\b ) # Links | (?P \<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>) | (?P \[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\]) # Inline HTML - | (?P <(/|)(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])[^>]*>) - | (?P [<>&]) + | (?P <(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])\b ) + | (?P ( /\s*> | ) ) + | (?P [<>&] ) # Auto links (LEGACY) | (?P \b[a-zA-Z0-9_/-]+\.(png|gif|jpg|jpeg|bmp|ico|ogm|ogg|mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt)) @@ -786,12 +798,7 @@ def main(): handler(form[cmd].value) break else: - path_info = os.environ.get('PATH_INFO', '') - if len(path_info) and path_info[0] == '/': - query = path_info[1:] or 'FrontPage' - else: - query = os.environ.get('QUERY_STRING', '') or 'FrontPage' - + query = query_string() if file_re.match(query): if word_re.match(query): Page(query).format()