diff --git a/VERSION b/VERSION index e64a7abe..5ff93dea 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.8 (2012-09-08 21:59:44) stable +Version 2.0.8 (2012-09-08 22:22:02) stable diff --git a/gluon/contrib/markmin/markmin2html.py b/gluon/contrib/markmin/markmin2html.py index ab75aeb5..bde911fb 100755 --- a/gluon/contrib/markmin/markmin2html.py +++ b/gluon/contrib/markmin/markmin2html.py @@ -559,6 +559,29 @@ def markmin_escape(text): return regex_markmin_escape.sub( lambda m: '\\'+m.group(0).replace('\\','\\\\'), text) +def replace_autolinks(text,autolinks): + return regex_auto.sub(lambda m: autolinks(m.group('k')), text) + +def replace_at_urls(text,url): + # this is experimental @{function/args} + # turns into a digitally signed URL + def u1(match,url=url): + a,c,f,args = match.group('a','c','f','args') + return url(a=a or None,c=c or None,f = f or None, + args=args.split('/'), scheme=True, host=True) + return regex_URL.sub(u1,text) + +def replace_components(text,env): + def u2(match, env=env): + f = env.get(match.group('a'), match.group(0)) + if callable(f): + try: + f = f(match.group('b')) + except Exception, e: + f = 'ERROR: %s' % e + return str(f) + return regex_env.sub(u2, text) + def autolinks_simple(url): """ it automatically converts the url to link, @@ -829,13 +852,7 @@ def render(text, text = regex_backslash.sub(lambda m: m.group(1).translate(ttab_in), text) if URL is not None: - # this is experimental @{function/args} - # turns into a digitally signed URL - def u1(match,URL=URL): - a,c,f,args = match.group('a','c','f','args') - return URL(a=a or None,c=c or None,f = f or None, - args=args.split('/'), scheme=True, host=True) - text = regex_URL.sub(u1,text) + text = replace_at_urls(text,URL) if latex == 'google': text = regex_dd.sub('``\g``:latex ', text) @@ -878,7 +895,7 @@ def render(text, text = regex_proto.sub(lambda m: protolinks(*m.group('p','k')), text) if autolinks: - text = regex_auto.sub(lambda m: autolinks(m.group('k')), text) + text = replace_autolinks(text,lambda m: autolinks(m.group('k'))) ############################################################# # normalize spaces @@ -1304,15 +1321,7 @@ def render(text, text = regex_expand_meta.sub(expand_meta, text) if environment: - def u2(match, environment=environment): - f = environment.get(match.group('a'), match.group(0)) - if callable(f): - try: - f = f(match.group('b')) - except Exception, e: - f = 'ERROR: %s' % e - return str(f) - text = regex_env.sub(u2, text) + text = replace_components(text,environment) return text.translate(ttab_out) diff --git a/gluon/tools.py b/gluon/tools.py index 75873cf5..8ae9fe9e 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -31,6 +31,8 @@ from utils import web2py_uuid from fileutils import read_file, check_credentials from gluon import * from gluon.contrib.autolinks import expand_one +from gluon.contrib.markmin.markmin2html import \ + replace_at_urls, replace_autolinks, replace_components from gluon.dal import Row import serializers @@ -4486,6 +4488,15 @@ class Wiki(object): *[A(t.strip(),_href=URL(args='_search',vars=dict(q=t))) for t in page.tags or [] if t.strip()]).xml() return html + def html_render(self,page): + html = page.body + # @///function -> http://..../function + html = replace_at_urls(html,URL) + # http://...jpg ->