summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-12-16 00:05:35 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-12-16 00:05:35 +0900
commit712c20a3d91cd80247c5625782ba8ada2b2c2378 (patch)
treed151c391d9bc18aa2ceffa455efa658bafc1ec29 /sphinx
parent5a03cac7d369ea71e1414792df62668ca5fd8190 (diff)
parentcb5fab5db90c2177ede34af876b19e58b9dc1263 (diff)
downloadsphinx-git-712c20a3d91cd80247c5625782ba8ada2b2c2378.tar.gz
Merge branch '2.0'
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/builders/__init__.py2
-rw-r--r--sphinx/builders/gettext.py4
-rw-r--r--sphinx/builders/latex/__init__.py13
-rw-r--r--sphinx/config.py6
-rw-r--r--sphinx/domains/std.py12
-rw-r--r--sphinx/highlighting.py1
-rw-r--r--sphinx/templates/gettext/message.pot_t4
-rw-r--r--sphinx/texinputs/sphinx.sty28
-rw-r--r--sphinx/texinputs/sphinx.xdy6
-rw-r--r--sphinx/util/nodes.py2
-rw-r--r--sphinx/util/texescape.py37
-rw-r--r--sphinx/writers/html.py20
-rw-r--r--sphinx/writers/html5.py23
-rw-r--r--sphinx/writers/latex.py26
14 files changed, 124 insertions, 60 deletions
diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py
index d2040498e..777536d3e 100644
--- a/sphinx/builders/__init__.py
+++ b/sphinx/builders/__init__.py
@@ -304,7 +304,7 @@ class Builder:
First updates the environment, and then calls :meth:`write`.
"""
if summary:
- logger.info(bold(__('building [%s]') % self.name) + ': ' + summary)
+ logger.info(bold(__('building [%s]: ') % self.name) + summary)
# while reading, collect all warnings from docutils
with logging.pending_warnings():
diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py
index ea6fa61a9..e7adb0b8c 100644
--- a/sphinx/builders/gettext.py
+++ b/sphinx/builders/gettext.py
@@ -282,6 +282,8 @@ class MessageCatalogBuilder(I18nBuilder):
'version': self.config.version,
'copyright': self.config.copyright,
'project': self.config.project,
+ 'last_translator': self.config.gettext_last_translator,
+ 'language_team': self.config.gettext_language_team,
'ctime': datetime.fromtimestamp(timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
'display_location': self.config.gettext_location,
'display_uuid': self.config.gettext_uuid,
@@ -311,6 +313,8 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('gettext_uuid', False, 'gettext')
app.add_config_value('gettext_auto_build', True, 'env')
app.add_config_value('gettext_additional_targets', [], 'env')
+ app.add_config_value('gettext_last_translator', 'FULL NAME <EMAIL@ADDRESS>', 'gettext')
+ app.add_config_value('gettext_language_team', 'LANGUAGE <LL@li.org>', 'gettext')
return {
'version': 'builtin',
diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py
index c24e87a13..de4223a0e 100644
--- a/sphinx/builders/latex/__init__.py
+++ b/sphinx/builders/latex/__init__.py
@@ -234,14 +234,13 @@ class LaTeXBuilder(Builder):
destination = SphinxFileOutput(destination_path=path.join(self.outdir, targetname),
encoding='utf-8', overwrite_if_changed=True)
with progress_message(__("processing %s") % targetname):
- toctrees = self.env.get_doctree(docname).traverse(addnodes.toctree)
- if toctrees:
- if toctrees[0].get('maxdepth') > 0:
- tocdepth = toctrees[0].get('maxdepth')
- else:
- tocdepth = None
+ doctree = self.env.get_doctree(docname)
+ toctree = next(iter(doctree.traverse(addnodes.toctree)), None)
+ if toctree and toctree.get('maxdepth') > 0:
+ tocdepth = toctree.get('maxdepth')
else:
tocdepth = None
+
doctree = self.assemble_doctree(
docname, toctree_only,
appendices=((docclass != 'howto') and self.config.latex_appendices or []))
@@ -465,7 +464,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('latex_logo', None, None, [str])
app.add_config_value('latex_appendices', [], None)
app.add_config_value('latex_use_latex_multicolumn', False, None)
- app.add_config_value('latex_use_xindy', default_latex_use_xindy, None)
+ app.add_config_value('latex_use_xindy', default_latex_use_xindy, None, [bool])
app.add_config_value('latex_toplevel_sectioning', None, None,
ENUM(None, 'part', 'chapter', 'section'))
app.add_config_value('latex_domain_indices', True, None, [list])
diff --git a/sphinx/config.py b/sphinx/config.py
index 691cdac11..c12841acb 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -186,6 +186,12 @@ class Config:
defvalue = self.values[name][0]
if self.values[name][2] == Any:
return value
+ elif type(defvalue) is bool or self.values[name][2] == [bool]:
+ if value == '0':
+ # given falsy string from command line option
+ return False
+ else:
+ return bool(value)
elif isinstance(defvalue, dict):
raise ValueError(__('cannot override dictionary config setting %r, '
'ignoring (use %r to set individual elements)') %
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 1e4f1b10f..10ca58c5b 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -611,15 +611,13 @@ class StandardDomain(Domain):
sectname = self.get_numfig_title(node)
if not sectname:
continue
- elif node.traverse(addnodes.toctree):
- n = node.traverse(addnodes.toctree)[0]
- if n.get('caption'):
- sectname = n['caption']
+ else:
+ toctree = next(iter(node.traverse(addnodes.toctree)), None)
+ if toctree and toctree.get('caption'):
+ sectname = toctree.get('caption')
else:
+ # anonymous-only labels
continue
- else:
- # anonymous-only labels
- continue
self.labels[name] = docname, labelid, sectname
def add_object(self, objtype: str, name: str, docname: str, labelid: str) -> None:
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index ca2bdc48f..c659114d8 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -164,6 +164,7 @@ class PygmentsBridge:
if self.dest == 'html':
return hlsource
else:
+ # MEMO: this is done to escape Unicode chars with non-Unicode engines
return texescape.hlescape(hlsource, self.latex_engine)
def get_stylesheet(self):
diff --git a/sphinx/templates/gettext/message.pot_t b/sphinx/templates/gettext/message.pot_t
index 90df27175..6bec78729 100644
--- a/sphinx/templates/gettext/message.pot_t
+++ b/sphinx/templates/gettext/message.pot_t
@@ -10,8 +10,8 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: {{ ctime|e }}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
+"Last-Translator: {{ last_translator|e }}\n"
+"Language-Team: {{ language_team|e }}\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty
index 5d9adb5bb..3e67b5610 100644
--- a/sphinx/texinputs/sphinx.sty
+++ b/sphinx/texinputs/sphinx.sty
@@ -1078,7 +1078,7 @@
}
\def\sphinx@verbatim@nolig@list {\do \`}%
-% Some characters . , ; ? ! / are not pygmentized.
+% Some characters . , ; ? ! / are neither pygmentized nor "tex-escaped".
% This macro makes them "active" and they will insert potential linebreaks.
% Not compatible with math mode (cf \sphinxunactivateextras).
\newcommand*\sphinxbreaksbeforeactivelist {}% none
@@ -1369,7 +1369,6 @@
}
\newcommand*\sphinxbreaksviaactiveinparsedliteral{%
\sphinxbreaksviaactive % by default handles . , ; ? ! /
- \do\-% we need also the hyphen character (ends up "as is" in parsed-literal)
\lccode`\~`\~ %
% update \dospecials as it is used by \url
% but deactivation will already have been done hence this is unneeded:
@@ -1380,7 +1379,7 @@
\lccode`~32 \lowercase{\let~}\spx@verbatim@space\lccode`\~`\~
}
\newcommand*{\sphinxunactivateextras}{\let\do\@makeother
- \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist\do\-}%
+ \sphinxbreaksbeforeactivelist\sphinxbreaksafteractivelist}%
% the \catcode13=5\relax (deactivate end of input lines) is left to callers
\newcommand*{\sphinxunactivateextrasandspace}{\catcode32=10\relax
\sphinxunactivateextras}%
@@ -1805,12 +1804,20 @@
% break also at \
\let\sphinx@textbackslash\textbackslash
\let\textbackslash\sphinxtextbackslash
- % do not typeset a continuation symbol on next line
+ % by default, no continuation symbol on next line but may be added
\let\sphinxafterbreak\sphinxafterbreakofinlineliteral
% do not overwrite the comma set-up
\let\verbatim@nolig@list\sphinx@literal@nolig@list
\fi
% fix a space-gobbling issue due to LaTeX's original \do@noligs
+% TODO: using \@noligs as patched by upquote.sty is now unneeded because
+% either ` and ' are escaped (non-unicode engines) or they don't build
+% ligatures (unicode engines). Thus remove this and unify handling of `, <, >,
+% ' and - with the characters . , ; ? ! / as handled via
+% \sphinxbreaksviaactive.
+% Hence \sphinx@do@noligs will be removed, or rather replaced with code
+% inserting discretionaries, as they allow a continuation symbol on start of
+% next line to achieve common design with code-blocks.
\let\do@noligs\sphinx@do@noligs
\@noligs\endlinechar\m@ne\everyeof{}% (<- in case inside \sphinxhref)
\expandafter\scantokens
@@ -1866,6 +1873,7 @@
% reduce hyperref "Token not allowed in a PDF string" warnings on PDF builds
\AtBeginDocument{\pdfstringdefDisableCommands{%
% all "protected" macros possibly ending up in section titles should be here
+% TODO: examine if \sphinxhref, \sphinxurl, \sphinnolinkurl should be handled
\let\sphinxstyleemphasis \@firstofone
\let\sphinxstyleliteralemphasis \@firstofone
\let\sphinxstylestrong \@firstofone
@@ -1879,8 +1887,20 @@
\let\sphinxemail \@firstofone
\let\sphinxcrossref \@firstofone
\let\sphinxtermref \@firstofone
+ \let\sphinxhyphen\sphinxhyphenforbookmarks
}}
+% Special characters
+%
+% This definition prevents en-dash and em-dash TeX ligatures.
+%
+% It inserts a potential breakpoint after the hyphen. This is to keep in sync
+% with behavior in code-blocks, parsed and inline literals. For a breakpoint
+% before the hyphen use \leavevmode\kern\z@- (within \makeatletter/\makeatother)
+\protected\def\sphinxhyphen#1{-\kern\z@}
+% The {} from texescape mark-up is kept, else -- gives en-dash in PDF bookmark
+\def\sphinxhyphenforbookmarks{-}
+
% For curly braces inside \index macro
\def\sphinxleftcurlybrace{\{}
\def\sphinxrightcurlybrace{\}}
diff --git a/sphinx/texinputs/sphinx.xdy b/sphinx/texinputs/sphinx.xdy
index 1c0794cd9..edca17874 100644
--- a/sphinx/texinputs/sphinx.xdy
+++ b/sphinx/texinputs/sphinx.xdy
@@ -112,12 +112,14 @@
(merge-rule "\_" "_" :string)
(merge-rule "{[}" "[" :string)
(merge-rule "{]}" "]" :string)
-(merge-rule "{}`" "`" :string)
(merge-rule "\textbackslash{}" "\" :string) ; " for Emacs syntax highlighting
(merge-rule "\textasciitilde{}" "~~" :string); the ~~ escape is needed here
+(merge-rule "\textasciicircum{}" "^" :string)
+(merge-rule "\sphinxhyphen{}" "-" :string)
+(merge-rule "\textquotesingle{}" "'" :string)
+(merge-rule "\textasciigrave{}" "`" :string)
(merge-rule "\textless{}" "<" :string)
(merge-rule "\textgreater{}" ">" :string)
-(merge-rule "\textasciicircum{}" "^" :string)
(merge-rule "\P{}" "¶" :string)
(merge-rule "\S{}" "§" :string)
(merge-rule "\texteuro{}" "€" :string)
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index 52e43c2e2..53b4d056e 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -148,7 +148,7 @@ def apply_source_workaround(node: Element) -> None:
logger.debug('[i18n] PATCH: %r to have rawsource: %s',
get_full_module_name(node), repr_domxml(node))
# strip classifier from rawsource of term
- for classifier in reversed(node.parent.traverse(nodes.classifier)):
+ for classifier in reversed(list(node.parent.traverse(nodes.classifier))):
node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
'', node.rawsource)
diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py
index b7928ce37..734809d1f 100644
--- a/sphinx/util/texescape.py
+++ b/sphinx/util/texescape.py
@@ -29,12 +29,6 @@ tex_replacements = [
# map chars to avoid mis-interpretation in LaTeX
('[', r'{[}'),
(']', r'{]}'),
- # map chars to avoid TeX ligatures
- # 1. ' - and , not here for some legacy reason
- # 2. no effect with lualatex (done otherwise: #5790)
- ('`', r'{}`'),
- ('<', r'\textless{}'),
- ('>', r'\textgreater{}'),
# map special Unicode characters to TeX commands
('✓', r'\(\checkmark\)'),
('✔', r'\(\pmb{\checkmark}\)'),
@@ -49,6 +43,23 @@ tex_replacements = [
# OHM SIGN U+2126 is handled by LaTeX textcomp package
]
+# A map to avoid TeX ligatures or character replacements in PDF output
+# xelatex/lualatex/uplatex are handled differently (#5790, #6888)
+ascii_tex_replacements = [
+ # Note: the " renders curly in OT1 encoding but straight in T1, T2A, LY1...
+ # escaping it to \textquotedbl would break documents using OT1
+ # Sphinx does \shorthandoff{"} to avoid problems with some languages
+ # There is no \text... LaTeX escape for the hyphen character -
+ ('-', r'\sphinxhyphen{}'), # -- and --- are TeX ligatures
+ # ,, is a TeX ligature in T1 encoding, but escaping the comma adds
+ # complications (whether by {}, or a macro) and is not done
+ # the next two require textcomp package
+ ("'", r'\textquotesingle{}'), # else ' renders curly, and '' is a ligature
+ ('`', r'\textasciigrave{}'), # else \` and \`\` render curly
+ ('<', r'\textless{}'), # < is inv. exclam in OT1, << is a T1-ligature
+ ('>', r'\textgreater{}'), # > is inv. quest. mark in 0T1, >> a T1-ligature
+]
+
# A map Unicode characters to LaTeX representation
# (for LaTeX engines which don't support unicode)
unicode_tex_replacements = [
@@ -85,6 +96,11 @@ unicode_tex_replacements = [
('₉', r'\(\sb{\text{9}}\)'),
]
+# TODO: this should be called tex_idescape_map because its only use is in
+# sphinx.writers.latex.LaTeXTranslator.idescape()
+# %, {, }, \, #, and ~ are the only ones which must be replaced by _ character
+# It would be simpler to define it entirely here rather than in init().
+# Unicode replacements are superfluous, as idescape() uses backslashreplace
tex_replace_map = {} # type: Dict[int, str]
_tex_escape_map = {} # type: Dict[int, str]
@@ -130,8 +146,17 @@ def init() -> None:
_tex_escape_map_without_unicode[ord(a)] = b
tex_replace_map[ord(a)] = '_'
+ # no reason to do this for _tex_escape_map_without_unicode
+ for a, b in ascii_tex_replacements:
+ _tex_escape_map[ord(a)] = b
+
+ # but the hyphen has a specific PDF bookmark problem
+ # https://github.com/latex3/hyperref/issues/112
+ _tex_escape_map_without_unicode[ord('-')] = r'\sphinxhyphen{}'
+
for a, b in unicode_tex_replacements:
_tex_escape_map[ord(a)] = b
+ # This is actually unneeded:
tex_replace_map[ord(a)] = '_'
for a, b in tex_replacements:
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index 0cbaef527..eac446793 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -13,7 +13,7 @@ import os
import posixpath
import warnings
from typing import cast
-from typing import Iterable
+from typing import Iterable, Tuple
from docutils import nodes
from docutils.nodes import Element, Node, Text
@@ -271,10 +271,9 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
def depart_seealso(self, node: Element) -> None:
self.depart_admonition(node)
- def add_secnumber(self, node: Element) -> None:
+ def get_secnumber(self, node: Element) -> Tuple[int, ...]:
if node.get('secnumber'):
- self.body.append('.'.join(map(str, node['secnumber'])) +
- self.secnumber_suffix)
+ return node['secnumber']
elif isinstance(node.parent, nodes.section):
if self.builder.name == 'singlehtml':
docname = self.docnames[-1]
@@ -285,10 +284,17 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator):
anchorname = '#' + node.parent['ids'][0]
if anchorname not in self.builder.secnumbers:
anchorname = '' # try first heading which has no anchor
+
if self.builder.secnumbers.get(anchorname):
- numbers = self.builder.secnumbers[anchorname]
- self.body.append('.'.join(map(str, numbers)) +
- self.secnumber_suffix)
+ return self.builder.secnumbers[anchorname]
+
+ return None
+
+ def add_secnumber(self, node: Element) -> None:
+ secnumber = self.get_secnumber(node)
+ if secnumber:
+ self.body.append('<span class="section-number">%s</span>' %
+ ('.'.join(map(str, secnumber)) + self.secnumber_suffix))
def add_fignumber(self, node: Element) -> None:
def append_fignumber(figtype: str, figure_id: str) -> None:
diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py
index 3e67e4d1c..438f161f7 100644
--- a/sphinx/writers/html5.py
+++ b/sphinx/writers/html5.py
@@ -12,7 +12,7 @@ import os
import posixpath
import warnings
from typing import cast
-from typing import Iterable
+from typing import Iterable, Tuple
from docutils import nodes
from docutils.nodes import Element, Node, Text
@@ -242,11 +242,11 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
def depart_seealso(self, node: Element) -> None:
self.depart_admonition(node)
- def add_secnumber(self, node: Element) -> None:
+ def get_secnumber(self, node: Element) -> Tuple[int, ...]:
if node.get('secnumber'):
- self.body.append('.'.join(map(str, node['secnumber'])) +
- self.secnumber_suffix)
- elif isinstance(node.parent, nodes.section):
+ return node['secnumber']
+
+ if isinstance(node.parent, nodes.section):
if self.builder.name == 'singlehtml':
docname = self.docnames[-1]
anchorname = "%s/#%s" % (docname, node.parent['ids'][0])
@@ -256,10 +256,17 @@ class HTML5Translator(SphinxTranslator, BaseTranslator):
anchorname = '#' + node.parent['ids'][0]
if anchorname not in self.builder.secnumbers:
anchorname = '' # try first heading which has no anchor
+
if self.builder.secnumbers.get(anchorname):
- numbers = self.builder.secnumbers[anchorname]
- self.body.append('.'.join(map(str, numbers)) +
- self.secnumber_suffix)
+ return self.builder.secnumbers[anchorname]
+
+ return None
+
+ def add_secnumber(self, node: Element) -> None:
+ secnumber = self.get_secnumber(node)
+ if secnumber:
+ self.body.append('<span class="section-number">%s</span>' %
+ ('.'.join(map(str, secnumber)) + self.secnumber_suffix))
def add_fignumber(self, node: Element) -> None:
def append_fignumber(figtype: str, figure_id: str) -> None:
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 4f22851c9..e5573c182 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -473,7 +473,6 @@ class LaTeXTranslator(SphinxTranslator):
self.first_document = 1
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
@@ -958,13 +957,11 @@ class LaTeXTranslator(SphinxTranslator):
def visit_desc_name(self, node: Element) -> None:
self.body.append(r'\sphinxbfcode{\sphinxupquote{')
- self.no_contractions += 1
self.literal_whitespace += 1
def depart_desc_name(self, node: Element) -> None:
self.body.append('}}')
self.literal_whitespace -= 1
- self.no_contractions -= 1
def visit_desc_parameterlist(self, node: Element) -> None:
# close name, open parameterlist
@@ -1806,11 +1803,9 @@ class LaTeXTranslator(SphinxTranslator):
def visit_literal_emphasis(self, node: Element) -> None:
self.body.append(r'\sphinxstyleliteralemphasis{\sphinxupquote{')
- self.no_contractions += 1
def depart_literal_emphasis(self, node: Element) -> None:
self.body.append('}}')
- self.no_contractions -= 1
def visit_strong(self, node: Element) -> None:
self.body.append(r'\sphinxstylestrong{')
@@ -1820,11 +1815,9 @@ class LaTeXTranslator(SphinxTranslator):
def visit_literal_strong(self, node: Element) -> None:
self.body.append(r'\sphinxstyleliteralstrong{\sphinxupquote{')
- self.no_contractions += 1
def depart_literal_strong(self, node: Element) -> None:
self.body.append('}}')
- self.no_contractions -= 1
def visit_abbreviation(self, node: Element) -> None:
abbr = node.astext()
@@ -1884,14 +1877,12 @@ class LaTeXTranslator(SphinxTranslator):
pass
def visit_literal(self, node: Element) -> None:
- self.no_contractions += 1
if self.in_title:
self.body.append(r'\sphinxstyleliteralintitle{\sphinxupquote{')
else:
self.body.append(r'\sphinxcode{\sphinxupquote{')
def depart_literal(self, node: Element) -> None:
- self.no_contractions -= 1
self.body.append('}}')
def visit_footnote_reference(self, node: Element) -> None:
@@ -2065,9 +2056,7 @@ class LaTeXTranslator(SphinxTranslator):
def visit_option_string(self, node: Element) -> None:
ostring = node.astext()
- self.no_contractions += 1
self.body.append(self.encode(ostring))
- self.no_contractions -= 1
raise nodes.SkipNode
def visit_description(self, node: Element) -> None:
@@ -2151,14 +2140,15 @@ class LaTeXTranslator(SphinxTranslator):
# Insert a blank before the newline, to avoid
# ! LaTeX Error: There's no line here to end.
text = text.replace('\n', '~\\\\\n').replace(' ', '~')
- if self.no_contractions:
- text = text.replace('--', '-{-}')
- text = text.replace("''", "'{'}")
return text
def encode_uri(self, text: str) -> str:
+ # TODO: it is probably wrong that this uses texescape.escape()
+ # this must be checked against hyperref package exact dealings
+ # mainly, %, #, {, } and \ need escaping via a \ escape
# in \href, the tilde is allowed and must be represented literally
- return self.encode(text).replace('\\textasciitilde{}', '~')
+ return self.encode(text).replace('\\textasciitilde{}', '~').\
+ replace('\\sphinxhyphen{}', '-')
def visit_Text(self, node: Text) -> None:
text = self.encode(node.astext())
@@ -2247,6 +2237,12 @@ class LaTeXTranslator(SphinxTranslator):
fnotes[num] = [newnode, False]
return fnotes
+ @property
+ def no_contractions(self) -> int:
+ warnings.warn('LaTeXTranslator.no_contractions is deprecated.',
+ RemovedInSphinx40Warning, stacklevel=2)
+ return 0
+
def babel_defmacro(self, name: str, definition: str) -> str:
warnings.warn('babel_defmacro() is deprecated.',
RemovedInSphinx40Warning)