MARKMIN(...,_class='...')
This commit is contained in:
2
VERSION
2
VERSION
@@ -1 +1 @@
|
||||
Version 2.8.2-stable+timestamp.2014.01.11.15.02.21
|
||||
Version 2.8.2-stable+timestamp.2014.01.11.15.18.53
|
||||
|
||||
@@ -2694,55 +2694,27 @@ def markmin_serializer(text, tag=None, attr=None):
|
||||
return text
|
||||
|
||||
|
||||
class MARKMIN(XmlComponent):
|
||||
def MARKMIN(text, extra=None, allowed=None, sep='p',
|
||||
url=None, environment=None, latex='google',
|
||||
autolinks='default',
|
||||
protolinks='default',
|
||||
class_prefix='',
|
||||
id_prefix='markmin_',
|
||||
**kwargs):
|
||||
"""
|
||||
For documentation: http://web2py.com/examples/static/markmin.html
|
||||
"""
|
||||
def __init__(self, text, extra=None, allowed=None, sep='p',
|
||||
url=None, environment=None, latex='google',
|
||||
autolinks='default',
|
||||
protolinks='default',
|
||||
class_prefix='',
|
||||
id_prefix='markmin_'):
|
||||
self.text = text
|
||||
self.extra = extra or {}
|
||||
self.allowed = allowed or {}
|
||||
self.sep = sep
|
||||
self.url = URL if url == True else url
|
||||
self.environment = environment
|
||||
self.latex = latex
|
||||
self.autolinks = autolinks
|
||||
self.protolinks = protolinks
|
||||
self.class_prefix = class_prefix
|
||||
self.id_prefix = id_prefix
|
||||
|
||||
def xml(self):
|
||||
"""
|
||||
calls the gluon.contrib.markmin render function to convert the wiki syntax
|
||||
"""
|
||||
from gluon.contrib.markmin.markmin2html import render
|
||||
return render(self.text, extra=self.extra,
|
||||
allowed=self.allowed, sep=self.sep, latex=self.latex,
|
||||
URL=self.url, environment=self.environment,
|
||||
autolinks=self.autolinks, protolinks=self.protolinks,
|
||||
class_prefix=self.class_prefix, id_prefix=self.id_prefix)
|
||||
|
||||
def __str__(self):
|
||||
return self.xml()
|
||||
|
||||
def flatten(self, render=None):
|
||||
"""
|
||||
return the text stored by the MARKMIN object rendered by the render function
|
||||
"""
|
||||
return self.text
|
||||
|
||||
def elements(self, *args, **kargs):
|
||||
"""
|
||||
to be considered experimental since the behavior of this method is questionable
|
||||
another options could be TAG(self.text).elements(*args,**kargs)
|
||||
"""
|
||||
return [self.text]
|
||||
|
||||
from gluon.contrib.markmin.markmin2html import render
|
||||
extra = extra or {}
|
||||
allowed = allowed or {}
|
||||
url = URL if url == True else url
|
||||
text = render(text, extra=extra,
|
||||
allowed=allowed, sep=sep, latex=latex,
|
||||
URL=url, environment=environment,
|
||||
autolinks=autolinks, protolinks=protolinks,
|
||||
class_prefix=class_prefix, id_prefix=id_prefix)
|
||||
html = XML(text or '')
|
||||
return XML(html) if not kwargs else DIV(html,**kwargs)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
|
||||
Reference in New Issue
Block a user