fix tabulator display in preformatted and source nodes
authorvolker@brainbot.com
Thu Nov 20 14:40:24 2008 +0100 (6 weeks ago)
changeset 310e19f3bba6253
parent 30965d8d8b6c492
child 311bb5b820e3928
fix tabulator display in preformatted and source nodes
mwlib/rl/pdfstyles.py
mwlib/rl/rlwriter.py
       1 --- a/mwlib/rl/pdfstyles.py	Thu Nov 20 14:15:20 2008 +0100
       2 +++ b/mwlib/rl/pdfstyles.py	Thu Nov 20 14:40:24 2008 +0100
       3 @@ -104,8 +104,8 @@
       4  showTitlePageFooter = True
       5  pageBreakAfterArticle = False
       6  
       7 -showArticleSource = True 	# Set to False in customConfig.py to exclude article source URL from the output.
       8 -showArticleAuthors = True	# Set to False in customConfig.py to exclude principal author information from the output.
       9 +showArticleSource = True        # Set to False in customConfig.py to exclude article source URL from the output.
      10 +showArticleAuthors = True       # Set to False in customConfig.py to exclude principal author information from the output.
      11  
      12  # NOTE: strings can contain reportlab styling tags the text needs to be xml excaped.
      13  # more information is available in the reportlab user documentation (http://www.reportlab.com/docs/userguide.pdf)
      14 @@ -142,6 +142,8 @@
      15  LEFTINDENT = 25 # indentation of paragraphs...
      16  RIGHTINDENT = 25 # indentation of paragraphs...
      17  LISTINDENT = 12 # indentation of lists per level
      18 +
      19 +tabsize = 6
      20  
      21  maxCharsInSourceLine = 72 # if printing a source node, the maximum number of chars in one line
      22  
     1.1 --- a/mwlib/rl/rlwriter.py	Thu Nov 20 14:15:20 2008 +0100
     1.2 +++ b/mwlib/rl/rlwriter.py	Thu Nov 20 14:40:24 2008 +0100
     1.3 @@ -722,6 +722,7 @@
     1.4          txt.extend(self.renderInline(obj))
     1.5          t = ''.join(txt)
     1.6          t = re.sub( u'<br */>', u'\n', t)
     1.7 +        t = t.replace('\t', ' '*pdfstyles.tabsize)
     1.8          self.pre_mode = False
     1.9          if not len(t):
    1.10              return []
    1.11 @@ -981,10 +982,10 @@
    1.12              return [''.join(txt)]           
    1.13              
    1.14          if not obj.children:
    1.15 -            linktext = '[%s]' % len(self.references)
    1.16 +            linktext = '<link href="%s">[%s]</link>' % (xmlescape(href), len(self.references))
    1.17          else:
    1.18              linktext = self.renderInline(obj)
    1.19 -            linktext.append(' <super><font size="10">[%s]</font></super> ' % len(self.references))           
    1.20 +            linktext.append(' <super><link href="%s"><font size="10">[%s]</font></link></super> ' % (xmlescape(href), len(self.references)))
    1.21              linktext = ''.join(linktext).strip()
    1.22          return linktext
    1.23                 
    1.24 @@ -1194,6 +1195,7 @@
    1.25          sourceFormatter = ReportlabFormatter(font_size=FONTSIZE, font_name='DejaVuSansMono', background_color='#eeeeee', line_numbers=False)
    1.26          sourceFormatter.encoding = 'utf-8'
    1.27          source = ''.join(self.renderInline(n))
    1.28 +        source = source.replace('\t', ' '*pdfstyles.tabsize)
    1.29          maxCharOnLine = max( [ len(line) for line in source.split("\n")])
    1.30          char_limit = max(1, int(maxCharsInSourceLine / (max(1, self.currentColCount))))
    1.31