From 3135d3802d4f6d388c0fff06a9f6c5a9a9183b98 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 23 Mar 2008 19:33:12 +0000 Subject: [PATCH] Add missing commands if Pygments is not installed. Bug reported by Ondrej Certik. --- CHANGES | 3 +++ sphinx/highlighting.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 0c4862601..4c3bd385d 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,9 @@ Changes in trunk files (under _sources) as input files if the source suffix is ``.txt``. +* sphinx.highlighting: Generate correct markup for LaTeX Verbatim + environment escapes even if Pygments is not installed. + Release 0.1.61798 (Mar 23, 2008) ================================ diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index a46f0c449..0da8a61df 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -65,6 +65,13 @@ def escape_tex(text): replace('\x01', '@lb[]').\ replace('\x02', '@rb[]') +# used if Pygments is not available +_LATEX_STYLES = r''' +\newcommand\at{@} +\newcommand\lb{[} +\newcommand\rb{]} +''' + parsing_exceptions = (SyntaxError, UnicodeEncodeError) if sys.version_info < (2, 5): @@ -139,5 +146,9 @@ class PygmentsBridge(object): def get_stylesheet(self): if not pygments: + if self.dest == 'latex': + return _LATEX_STYLES + # no HTML styles needed return '' - return (self.dest == 'html' and self.hfmter or self.lfmter)[0].get_style_defs() + fmter = (self.dest == 'html' and self.hfmter or self.lfmter)[0] + return fmter.get_style_defs()