From 53abebda699551a460bb0b8e60982304e5b96415 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 25 Mar 2014 10:26:20 +0100 Subject: [PATCH] Closes #636: Keep straight single quotes in literal blocks in the LaTeX build. --- CHANGES | 1 + sphinx/highlighting.py | 8 +++++++- sphinx/texinputs/sphinx.sty | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index cee5275c5..0f9fbd0b7 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Release 1.2.3 (in development) Bugs fixed ---------- +* #636: Keep straight single quotes in literal blocks in the LaTeX build. * #1419: Generated i18n sphinx.js files are missing message catalog entries from '.js_t' and '.html'. The issue was introduced from Sphinx-1.1 * #1363: Fix i18n: missing python domain's cross-references with currentmodule diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index f9abb7d35..600a7cf08 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -63,6 +63,12 @@ _LATEX_STYLES = r''' \newcommand\PYGZcb{\char`\}} ''' +# used if Pygments is available +# use textcomp quote to get a true single quote +_LATEX_ADD_STYLES = r''' +\renewcommand\PYGZsq{\textquotesingle} +''' + parsing_exceptions = (SyntaxError, UnicodeEncodeError) if sys.version_info < (2, 5): # Python <= 2.4 raises MemoryError when parsing an @@ -231,4 +237,4 @@ class PygmentsBridge(object): if self.dest == 'html': return formatter.get_style_defs('.highlight') else: - return formatter.get_style_defs() + return formatter.get_style_defs() + _LATEX_ADD_STYLES diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 554845f83..ee0a923d0 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -32,6 +32,8 @@ \RequirePackage{parskip} % For parsed-literal blocks. \RequirePackage{alltt} +% Display "real" single quotes in literal blocks. +\RequirePackage{upquote} % Redefine these colors to your liking in the preamble. \definecolor{TitleColor}{rgb}{0.126,0.263,0.361}