From 0e95fba28df698e8d9c28624497d42f8712b6df3 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sat, 11 Jan 2014 15:19:38 -0600 Subject: [PATCH] MARKMIN(...,_class='...') --- VERSION | 2 +- gluon/html.py | 64 +++++++++++++++------------------------------------ 2 files changed, 19 insertions(+), 47 deletions(-) diff --git a/VERSION b/VERSION index 3a50315d..7ba0089e 100644 --- a/VERSION +++ b/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 diff --git a/gluon/html.py b/gluon/html.py index d78a19d2..3753ee3a 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -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