MARKMIN('@{a} @{c/f/args}',url=True,environment=dict(a='xxx'))
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 1.99.7 (2012-04-05 20:28:05) dev
|
Version 1.99.7 (2012-04-05 21:44:41) dev
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ regex_auto_video = re.compile('(?<!["\w\>/=])(?P<k>\w+://\S+\.(mp4|mpeg|mov)(\?\
|
|||||||
regex_auto_audio = re.compile('(?<!["\w\>/=])(?P<k>\w+://\S+\.(mp3|wav)(\?\S+)?)',re.M)
|
regex_auto_audio = re.compile('(?<!["\w\>/=])(?P<k>\w+://\S+\.(mp3|wav)(\?\S+)?)',re.M)
|
||||||
regex_auto = re.compile('(?<!["\w\>/=])(?P<k>\w+://\S+)',re.M)
|
regex_auto = re.compile('(?<!["\w\>/=])(?P<k>\w+://\S+)',re.M)
|
||||||
|
|
||||||
def render(text,extra={},allowed={},sep='p'):
|
def render(text,extra={},allowed={},sep='p',URL=None,environment=None):
|
||||||
"""
|
"""
|
||||||
Arguments:
|
Arguments:
|
||||||
- text is the text to be processed
|
- text is the text to be processed
|
||||||
@@ -356,6 +356,22 @@ def render(text,extra={},allowed={},sep='p'):
|
|||||||
<img src="http://chart.apis.google.com/chart?cht=tx&chl=\\int_a^b sin(x)dx" />
|
<img src="http://chart.apis.google.com/chart?cht=tx&chl=\\int_a^b sin(x)dx" />
|
||||||
"""
|
"""
|
||||||
text = str(text or '')
|
text = str(text or '')
|
||||||
|
if environment:
|
||||||
|
def u2(match,environment=environment):
|
||||||
|
a = match.group('a')
|
||||||
|
return str(environment[a])
|
||||||
|
text = re.compile('@\{(?P<a>\w+?)\}').sub(u2,text)
|
||||||
|
if not URL is None:
|
||||||
|
# this is experimental @{controller/index/args}
|
||||||
|
# turns into a digitally signed URL
|
||||||
|
def u1(match,URL=URL):
|
||||||
|
a,b,c = match.group('a'), match.group('b'), match.group('c')
|
||||||
|
return URL(a,b,args=c.split('/'),
|
||||||
|
scheme=True,host=True,user_signature=True)
|
||||||
|
text = re.compile(
|
||||||
|
'@\{(?P<a>\w+)/(?P<b>\w+)/(?P<c>.+?)\}'
|
||||||
|
).sub(u1,text)
|
||||||
|
|
||||||
#############################################################
|
#############################################################
|
||||||
# replace all blocks marked with ``...``:class with META
|
# replace all blocks marked with ``...``:class with META
|
||||||
# store them into segments they will be treated as code
|
# store them into segments they will be treated as code
|
||||||
|
|||||||
+7
-2
@@ -2322,18 +2322,23 @@ class MARKMIN(XmlComponent):
|
|||||||
"""
|
"""
|
||||||
For documentation: http://web2py.com/examples/static/markmin.html
|
For documentation: http://web2py.com/examples/static/markmin.html
|
||||||
"""
|
"""
|
||||||
def __init__(self, text, extra=None, allowed=None, sep='p'):
|
def __init__(self, text, extra=None, allowed=None, sep='p',
|
||||||
|
url=None, environment=None):
|
||||||
self.text = text
|
self.text = text
|
||||||
self.extra = extra or {}
|
self.extra = extra or {}
|
||||||
self.allowed = allowed or {}
|
self.allowed = allowed or {}
|
||||||
self.sep = sep
|
self.sep = sep
|
||||||
|
self.url = URL if url==True else url
|
||||||
|
self.environment = environment
|
||||||
|
|
||||||
def xml(self):
|
def xml(self):
|
||||||
"""
|
"""
|
||||||
calls the gluon.contrib.markmin render function to convert the wiki syntax
|
calls the gluon.contrib.markmin render function to convert the wiki syntax
|
||||||
"""
|
"""
|
||||||
from contrib.markmin.markmin2html import render
|
from contrib.markmin.markmin2html import render
|
||||||
return render(self.text,extra=self.extra,allowed=self.allowed,sep=self.sep)
|
return render(self.text,extra=self.extra,
|
||||||
|
allowed=self.allowed,sep=self.sep,
|
||||||
|
URL=self.url, environment=self.environment)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.xml()
|
return self.xml()
|
||||||
|
|||||||
Reference in New Issue
Block a user