diff --git a/CHANGES b/CHANGES index 6b46f933f..91f26fe35 100644 --- a/CHANGES +++ b/CHANGES @@ -36,6 +36,11 @@ Bugs fixed * #3337: Ugly rendering of definition list term's classifier * #3335: gettext does not extract field_name of a field in a field_list * #2952: C++, fix refs to operator() functions. +* Fix Unicode super- and subscript digits in :rst:dir:`code-block` and + :dudir:`parsed-literal` LaTeX output (ref #3342) +* LaTeX writer: leave ``"`` character inside :dudir:`parsed-literal` as is + (ref #3341) +* #3234: intersphinx failed for encoded inventories * #3158: too much space after captions in PDF output diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index ed37c083e..94b3e658a 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -29,6 +29,7 @@ from __future__ import print_function import time import zlib import codecs +import functools import posixpath from os import path import re @@ -164,6 +165,9 @@ def _read_from_url(url, config=None): r = requests.get(url, stream=True, config=config, timeout=config.intersphinx_timeout) r.raise_for_status() r.raw.url = r.url + # decode content-body based on the header. + # ref: https://github.com/kennethreitz/requests/issues/2155 + r.raw.read = functools.partial(r.raw.read, decode_content=True) return r.raw diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py index 8101a8fbf..60f3d8322 100644 --- a/sphinx/util/texescape.py +++ b/sphinx/util/texescape.py @@ -48,26 +48,26 @@ tex_replacements = [ ('│', r'\textbar{}'), ('ℯ', r'e'), ('ⅈ', r'i'), - ('⁰', r'$^\text{0}$'), - ('¹', r'$^\text{1}$'), - ('²', r'$^\text{2}$'), - ('³', r'$^\text{3}$'), - ('⁴', r'$^\text{4}$'), - ('⁵', r'$^\text{5}$'), - ('⁶', r'$^\text{6}$'), - ('⁷', r'$^\text{7}$'), - ('⁸', r'$^\text{8}$'), - ('⁹', r'$^\text{9}$'), - ('₀', r'$_\text{0}$'), - ('₁', r'$_\text{1}$'), - ('₂', r'$_\text{2}$'), - ('₃', r'$_\text{3}$'), - ('₄', r'$_\text{4}$'), - ('₅', r'$_\text{5}$'), - ('₆', r'$_\text{6}$'), - ('₇', r'$_\text{7}$'), - ('₈', r'$_\text{8}$'), - ('₉', r'$_\text{9}$'), + ('⁰', r'\(\sp{\text{0}}\)'), + ('¹', r'\(\sp{\text{1}}\)'), + ('²', r'\(\sp{\text{2}}\)'), + ('³', r'\(\sp{\text{3}}\)'), + ('⁴', r'\(\sp{\text{4}}\)'), + ('⁵', r'\(\sp{\text{5}}\)'), + ('⁶', r'\(\sp{\text{6}}\)'), + ('⁷', r'\(\sp{\text{7}}\)'), + ('⁸', r'\(\sp{\text{8}}\)'), + ('⁹', r'\(\sp{\text{9}}\)'), + ('₀', r'\(\sb{\text{0}}\)'), + ('₁', r'\(\sb{\text{1}}\)'), + ('₂', r'\(\sb{\text{2}}\)'), + ('₃', r'\(\sb{\text{3}}\)'), + ('₄', r'\(\sb{\text{4}}\)'), + ('₅', r'\(\sb{\text{5}}\)'), + ('₆', r'\(\sb{\text{6}}\)'), + ('₇', r'\(\sb{\text{7}}\)'), + ('₈', r'\(\sb{\text{8}}\)'), + ('₉', r'\(\sb{\text{9}}\)'), # map Greek alphabet ('α', r'\(\alpha\)'), ('β', r'\(\beta\)'), diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 11ccfe0f1..ddbf73c0a 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -355,6 +355,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.this_is_the_title = 1 self.literal_whitespace = 0 self.no_contractions = 0 + self.in_parsed_literal = 0 self.compact_list = 0 self.first_param = 0 self.remember_multirow = {} @@ -1927,6 +1928,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_literal_block(self, node): if node.rawsource != node.astext(): # most probably a parsed-literal block -- don't highlight + self.in_parsed_literal += 1 self.body.append('\\begin{alltt}\n') else: ids = '' @@ -1988,6 +1990,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def depart_literal_block(self, node): self.body.append('\n\\end{alltt}\n') + self.in_parsed_literal -= 1 visit_doctest_block = visit_literal_block depart_doctest_block = depart_literal_block @@ -2190,7 +2193,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_Text(self, node): text = self.encode(node.astext()) - if not self.no_contractions: + if not self.no_contractions and not self.in_parsed_literal: text = educate_quotes_latex(text) self.body.append(text)