changeset 3200:6a83a46ccf59

Added support for the comment elements by implementing the div and span functions. The comment is mapped as the remark entity in docbook which can really only be inline, so using the div system might produce invalid docbooks.
author Mikko Virkkil? <mvirkkil@cc.hut.fi>
date Thu, 06 Mar 2008 01:29:59 +0100
parents 593d2e6265ce
children e26c52c2ef0b
files MoinMoin/formatter/text_docbook.py
diffstat 1 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/formatter/text_docbook.py	Wed Mar 05 22:48:30 2008 +0100
+++ b/MoinMoin/formatter/text_docbook.py	Thu Mar 06 01:29:59 2008 +0100
@@ -730,6 +730,43 @@
         self._emitComment("RAW HTML: "+markup)
         return ""
 
+    def div(self, on, **kw):
+        """A div cannot really be supported in DocBook as it carries no
+        semantic meaning, but the special case of a comment can be handled.
+        
+        A comment is represented in DocBook by the remark element.
+                
+        A comment div is recognized by the fact that it has the class 
+        "comment". Other cases of div use are ignored.
+        
+        Note: The remark entity can only contain inline elements, so it is
+              likely that the use of this will produce invalid DocBook.
+        """
+        css_class = kw.get('css_class')
+        if on and css_class and 'comment' in css_class.split():
+            self._handleFormatting("remark", on)
+        if not on and self.cur.nodeName == "remark":
+            self._handleFormatting("remark", on)
+        return ""
+        
+    def span(self, on, **kw):
+        """A span cannot really be supported in DocBook as it carries no
+        semantic meaning, but the special case of a comment can be handled.
+        
+        A comment is represented in DocBook by the remark element.
+        
+        A comment span is recognized by the fact that it has the class 
+        "comment". Other cases of div use are ignored.
+        """
+        css_class = kw.get('css_class')
+        if on and css_class and 'comment' in css_class.split():
+            self._handleFormatting("remark", on)
+        if not on and self.cur.nodeName == "remark":
+            self._handleFormatting("remark", on)
+        return ""
+                        
+    
+    
 ### Tables ##########################################################
 
     def table(self, on, attrs=(), **kw):