Edgewall Software

Ticket #5654: tracpygments-options.diff

File tracpygments-options.diff, 1.7 KB (added by Tim Hatch, 18 years ago)

First version, against r2367 for tracpygments

  • __init__.py

     
    6060        to override the default quality ratio used by the
    6161        Pygments render.""")
    6262
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
    6373    expand_tabs = True
    6474    returns_source = True
    6575
     
    218228                    Mimeview(self.env).configured_modes_mapping('pygments')
    219229                )
    220230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
    221241    def _highlight(self, language, content, annotate):
     242
    222243        formatter = HtmlFormatter(cssclass=not annotate and 'code' or '')
    223         html = pygments.highlight(content, get_lexer_by_name(language),
     244        opts = self._options.get(language, {})
     245        opts['stripnl'] = False
     246        lexer = get_lexer_by_name(language, **opts)
     247        html = pygments.highlight(content, lexer,
    224248                                  formatter).rstrip('\n')
    225249        if annotate:
    226250            return html[len('<div><pre>'):-len('</pre></div>')].splitlines()