reportlab: add fix for <para/> and new test
authorrgbecker
Thu, 18 Nov 2004 14:23:20 +0000
changeset 2410 f505ed647678
parent 2409 0a056aeb6a2c
child 2411 43cd3afa485b
reportlab: add fix for <para/> and new test
reportlab/platypus/paraparser.py
reportlab/test/test_platypus_paragraphs.py
--- a/reportlab/platypus/paraparser.py	Sat Nov 13 10:14:23 2004 +0000
+++ b/reportlab/platypus/paraparser.py	Thu Nov 18 14:23:20 2004 +0000
@@ -19,7 +19,7 @@
 from reportlab.lib.fonts import tt2ps, ps2tt
 from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 from reportlab.lib.units import inch,mm,cm,pica
-_re_para = re.compile('^\\s*<\\s*para(\\s+|>)')
+_re_para = re.compile(r'^\s*<\s*para(?:\s+|>|/>)')
 
 sizeDelta = 2       # amount to reduce font size by for super and sub script
 subFraction = 0.5   # fraction of font size that a sub script should be lowered
--- a/reportlab/test/test_platypus_paragraphs.py	Sat Nov 13 10:14:23 2004 +0000
+++ b/reportlab/test/test_platypus_paragraphs.py	Thu Nov 18 14:23:20 2004 +0000
@@ -55,6 +55,26 @@
         self.addPageTemplates(template)
 
 
+class ParagraphCorners(unittest.TestCase):
+    "some corner cases which should parse"
+    def check(text,bt = getSampleStyleSheet()['BodyText']):
+        try:
+            P = Paragraph(text,st)
+        except:
+            raise AssertionError("'%s' should parse"%text)
+            
+    def test0(self):
+        self.check('<para />')
+        self.check('<para/>')
+        self.check('\t\t\t\n\n\n<para />')
+        self.check('\t\t\t\n\n\n<para/>')
+        self.check('<para\t\t\t\t/>')
+        self.check('<para></para>')
+        self.check('<para>      </para>')
+        self.check('\t\t\n\t\t\t   <para>      </para>')
+        
+
+
 class ParagraphSplitTestCase(unittest.TestCase):
     "Test multi-page splitting of paragraphs (eyeball-test)."