changeset 598:ed7033e4cafe

revived test_formatter, added some comments to broken dom_xml formatter
author tw@waldmann-edv.de
date Sun, 23 Apr 2006 15:17:37 +0200
parents 16519af337fe
children 6dddf31479c1
files MoinMoin/_tests/broken/test_formatter.py MoinMoin/_tests/test_formatter.py MoinMoin/formatter/dom_xml.py
diffstat 3 files changed, 60 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/broken/test_formatter.py	Sun Apr 23 00:15:38 2006 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - MoinMoin.formatter.* Tests
-
-    @copyright: 2005 by MoinMoin:AlexanderSchremmer
-    @license: GNU GPL, see COPYING for details.
-"""
-
-from unittest import TestCase
-import re
-from StringIO import StringIO
-from MoinMoin._tests import TestConfig
-from MoinMoin.Page import Page
-from MoinMoin.parser.wiki import Parser
-from MoinMoin import wikiutil
-
-
-class FormatterTestCase(TestCase):
-    def testSyntaxReference(self):
-        formatters = wikiutil.getPlugins("formatter", self.request.cfg)
-        for f_name in formatters:
-            #if f_name in ('dom_xml', ):
-            #    continue
-            
-            try:
-                formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
-            except wikiutil.PluginAttributeError:
-                pass
-            else:
-                print "Formatting using %r" % formatter
-                self.formatPage("SyntaxReference", formatter)
-                print "Done."
-
-    def formatPage(self, pagename, formatter):
-        """Parse a page. Should not raise an exception if the API of the
-        formatter is correct.
-        """
-
-        self.request.reset()
-        page = Page(self.request, pagename, formatter=formatter)
-        self.request.formatter = page.formatter = formatter(self.request)
-        #page.formatter.setPage(page)
-        #page.hilite_re = None
-        
-        return self.request.redirectedOutput(page.send_page, self.request)
-    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/_tests/test_formatter.py	Sun Apr 23 15:17:37 2006 +0200
@@ -0,0 +1,46 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - MoinMoin.formatter.* Tests
+
+    @copyright: 2005 by MoinMoin:AlexanderSchremmer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from unittest import TestCase
+import re
+from StringIO import StringIO
+from MoinMoin._tests import TestConfig
+from MoinMoin.Page import Page
+from MoinMoin.parser.wiki import Parser
+from MoinMoin import wikiutil
+
+
+class FormatterTestCase(TestCase):
+    def testSyntaxReference(self):
+        formatters = wikiutil.getPlugins("formatter", self.request.cfg)
+        for f_name in formatters:
+            #if f_name in ('dom_xml', ):
+            #    continue
+            
+            try:
+                formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
+            except wikiutil.PluginAttributeError:
+                pass
+            else:
+                print "Formatting using %r" % formatter
+                self.formatPage("SyntaxReference", formatter)
+                print "Done."
+
+    def formatPage(self, pagename, formatter):
+        """Parse a page. Should not raise an exception if the API of the
+        formatter is correct.
+        """
+
+        self.request.reset()
+        page = Page(self.request, pagename, formatter=formatter)
+        self.request.formatter = page.formatter = formatter(self.request)
+        #page.formatter.setPage(page)
+        #page.hilite_re = None
+        
+        return self.request.redirectedOutput(page.send_page, self.request)
+
--- a/MoinMoin/formatter/dom_xml.py	Sun Apr 23 00:15:38 2006 +0200
+++ b/MoinMoin/formatter/dom_xml.py	Sun Apr 23 15:17:37 2006 +0200
@@ -20,23 +20,23 @@
         while navigational elements (HTML page header/footer) and the like
         can be printed directly without violating output abstraction.
     """
-
     hardspace = ' '
 
+    # those tags will be automatically reopened if they were auto-closed due to
+    # an enclosing tag being closed:
     format_tags = ['b', 'em', 'highlight', 'sup', 'sub', 'strike', 'code', 'u']
 
-    unbreakables = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6',
-                    'p', 'ol', 'ul', 'li', 'pre', 'a',
-                    'table', 'td', 'tr']
-
+    # those tags want a <p> around them:
     need_p = [] # format_tags[:]
     need_p.extend(['ol', 'a', 'pagelink', 'interwiki', 'macro']) # XXX add more
 
+    # those tags inhibit auto-generation of a <p> after them:
     no_p_after = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'ol', 'ul', 'pre',
                   'small', 'big', 'table', 'td', 'tr', 'dt',
                   'codearea', 'codeline', 'codetoken',
                   'sysmesg']
 
+    # if key tag is opened, auto-close all tags in value list if they are open
     close_on_open = {
         'h1': ['p'],
         'li': ['li'],
@@ -47,16 +47,18 @@
     for i in xrange(2, 7):
         close_on_open['h%i' % i] = close_on_open['h1']
 
-    close_on_open = {} # XXX
-
+    # if key tag is closed, auto-close all tags in value list if they are open
     close_on_close = {
         'table': ['td', 'tr'],
-        'td': ['tr'],
+        'td': ['tr'], # XXX WTF?
         'tr': ['td'],
         'ol': ['li'],
         'ul': ['li'],
         }
-    close_on_close = {} # XXX
+    
+    # XXX XXX XXX this overrides the values defined above - SENSE == ??? XXX XXX XXX
+    close_on_open = {}
+    close_on_close = {}
 
     def __init__(self, request, **kw):
         self.request = request
@@ -154,7 +156,7 @@
                 elif last_tag in self.format_tags:
                     tags_to_reopen.append(self._close_tag(last_tag))
                 else:
-                    print self.tag_stack
+                    self.request.write("tag_stack: %r\n" % self.tag_stack)
                     self.request.write(self.document.documentElement.toprettyxml(" "))
                     raise ValueError, "<%s> expected <%s> given" % (last_tag, tag)
             self._close_tag(tag)
@@ -177,8 +179,7 @@
     def sysmsg(self, on, **kw):
         """ Emit a system message (embed it into the page).
 
-            Normally used to indicate disabled options, or invalid
-            markup.
+            Normally used to indicate disabled options, or invalid markup.
         """
         return self._set_tag('sysmesg', on, **kw)
 
@@ -220,8 +221,7 @@
                 self.text('\n'.join(lines)) +
                 self._set_tag('processor', False))
 
-    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={},
-                        returns_content=1):
+    def dynamic_content(self, parser, callback, arg_list=[], arg_dict={}, returns_content=1):
         content = parser[callback](*arg_list, **arg_dict)
         if returns_content:
             return content