reportlab/test/test_platypus_paragraphs.py
changeset 2744 9472eedb9702
parent 2742 8edd54153201
child 2750 05229265aff3
equal deleted inserted replaced
2742:8edd54153201 2744:9472eedb9702
     8 from string import split, strip, join, whitespace
     8 from string import split, strip, join, whitespace
     9 from operator import truth
     9 from operator import truth
    10 from types import StringType, ListType
    10 from types import StringType, ListType
    11 
    11 
    12 from reportlab.test import unittest
    12 from reportlab.test import unittest
    13 from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation, outputfile
    13 from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
    14 
    14 
    15 from reportlab.pdfbase.pdfmetrics import stringWidth
    15 from reportlab.pdfbase.pdfmetrics import stringWidth
    16 from reportlab.platypus.paraparser import ParaParser
    16 from reportlab.platypus.paraparser import ParaParser
    17 from reportlab.platypus.flowables import Flowable
    17 from reportlab.platypus.flowables import Flowable
    18 from reportlab.lib.colors import Color
    18 from reportlab.lib.colors import Color
   248 The following thesis:  most of the methodological work in modern
   248 The following thesis:  most of the methodological work in modern
   249 linguistics can be defined in such a way as to impose problems of
   249 linguistics can be defined in such a way as to impose problems of
   250 phonemic and morphological analysis.''']
   250 phonemic and morphological analysis.''']
   251         story =[]
   251         story =[]
   252         a = story.append
   252         a = story.append
       
   253         a(Paragraph("This should %lt;a href=\"#theEnd\" color=\"blue\"&gt;<a href=\"#theEnd\" color=\"blue\">jump</a>&lt;/a&gt; jump to the end!",style=normal))
       
   254         a(Paragraph("This should %lt;a href=\"#thePenultimate\" color=\"blue\"&gt;<a href=\"#thePenultimate\" color=\"blue\">jump</a>&lt;/a&gt; jump to the penultimate page!",style=normal))
   253         for mode in (0,1):
   255         for mode in (0,1):
   254             text0 = texts[0]
   256             text0 = texts[0]
   255             text1 = texts[1]
   257             text1 = texts[1]
   256             if mode:
   258             if mode:
   257                 text0 = text0.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
   259                 text0 = text0.replace('English sentences','<b>English sentences</b>').replace('quite equivalent','<i>quite equivalent</i>')
   258                 text1 = text1.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
   260                 text1 = text1.replace('the methodological work','<b>the methodological work</b>').replace('to impose problems','<i>to impose problems</i>')
   259             for t in ('u','strike'):
   261             for t in ('u','strike'):
   260                 for n in xrange(6):
   262                 for n in xrange(6):
   261                     for s in (normal,normal_center,normal_right,normal_just,normal_indent, normal_indent_lv_2):
   263                     for s in (normal,normal_center,normal_right,normal_just,normal_indent, normal_indent_lv_2):
       
   264                         if n==4 and s==normal_center and t=='strike':
       
   265                             a(Paragraph("The second jump at the beginning should come here &lt;a name=\"thePenultimate\"/&gt;<a name=\"thePenultimate\"/>!",style=normal))
   262                         a(Paragraph('n=%d style=%s tag=%s'%(n,s.name,t),style=normal_sp))
   266                         a(Paragraph('n=%d style=%s tag=%s'%(n,s.name,t),style=normal_sp))
   263                         a(Paragraph('%s<%s>%s</%s>. %s <%s>%s</%s>. %s' % (
   267                         a(Paragraph('%s<%s>%s</%s>. %s <%s>%s</%s>. %s' % (
   264                         (s==normal_indent_lv_2 and '<seq id="document" inc="no"/>.<seq id="document_lv_2"/>' or ''),
   268                         (s==normal_indent_lv_2 and '<seq id="document" inc="no"/>.<seq id="document_lv_2"/>' or ''),
   265                         t,' '.join((n+1)*['A']),t,text0,t,' '.join((n+1)*['A']),t,text1),
   269                         t,' '.join((n+1)*['A']),t,text0,t,' '.join((n+1)*['A']),t,text1),
   266                         style=s))
   270                         style=s))
       
   271         a(Paragraph("The jump at the beginning should come here &lt;a name=\"theEnd\"/&gt;<a name=\"theEnd\"/>!",style=normal))
   267         doc = MyDocTemplate(outputfile('test_platypus_paragraphs_ul.pdf'))
   272         doc = MyDocTemplate(outputfile('test_platypus_paragraphs_ul.pdf'))
   268         doc.build(story)
   273         doc.build(story)
   269 
   274 
   270 class JustifyTestCase(unittest.TestCase):
   275 class JustifyTestCase(unittest.TestCase):
   271     "Test justification of paragraphs."
   276     "Test justification of paragraphs."