diff genshi/builder.py @ 737:686bbeecb9ac

Implement the `__html__` protocol as suggested in #202. This would allow Genshi to be used in combination with other markup generating tools, as long as they support the same protocol.
author cmlenz
date Thu, 05 Jun 2008 17:00:15 +0000
parents 92e2fb9c056f
children f7da2de9b293
line wrap: on
line diff
--- a/genshi/builder.py
+++ b/genshi/builder.py
@@ -73,7 +73,8 @@
 except NameError:
     from sets import Set as set
 
-from genshi.core import Attrs, Namespace, QName, Stream, START, END, TEXT
+from genshi.core import Attrs, Markup, Namespace, QName, Stream, \
+                        START, END, TEXT
 
 __all__ = ['Fragment', 'Element', 'ElementFactory', 'tag']
 __docformat__ = 'restructuredtext en'
@@ -112,6 +113,9 @@
     def __unicode__(self):
         return unicode(self.generate())
 
+    def __html__(self):
+        return Markup(self.generate())
+
     def append(self, node):
         """Append an element or string as child node.
         
Copyright (C) 2012-2017 Edgewall Software