hgext/highlight/__init__.py
changeset 42927 a7abc6081bc5
parent 41071 28a4fb793ba1
child 43076 2372284d9457
equal deleted inserted replaced
42926:8d9322b6e687 42927:a7abc6081bc5
    34     webutil,
    34     webutil,
    35 )
    35 )
    36 
    36 
    37 from mercurial import (
    37 from mercurial import (
    38     extensions,
    38     extensions,
       
    39     pycompat,
    39 )
    40 )
    40 
    41 
    41 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    42 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    42 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    43 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
    43 # be specifying the version(s) of Mercurial they are tested with, or
    44 # be specifying the version(s) of Mercurial they are tested with, or
    77 
    78 
    78     return orig(web)
    79     return orig(web)
    79 
    80 
    80 def generate_css(web):
    81 def generate_css(web):
    81     pg_style = web.config('web', 'pygments_style', 'colorful')
    82     pg_style = web.config('web', 'pygments_style', 'colorful')
    82     fmter = highlight.HtmlFormatter(style=pg_style)
    83     fmter = highlight.HtmlFormatter(style=pycompat.sysstr(pg_style))
    83     web.res.headers['Content-Type'] = 'text/css'
    84     web.res.headers['Content-Type'] = 'text/css'
       
    85     style_defs = fmter.get_style_defs(pycompat.sysstr(''))
    84     web.res.setbodybytes(''.join([
    86     web.res.setbodybytes(''.join([
    85         '/* pygments_style = %s */\n\n' % pg_style,
    87         '/* pygments_style = %s */\n\n' % pg_style,
    86         fmter.get_style_defs(''),
    88         pycompat.bytestr(style_defs),
    87     ]))
    89     ]))
    88     return web.res.sendresponse()
    90     return web.res.sendresponse()
    89 
    91 
    90 def extsetup(ui):
    92 def extsetup(ui):
    91     # monkeypatch in the new version
    93     # monkeypatch in the new version