Merge pull request #5045 from jfbu/latex_remove_shorthandoff_variable

Remove usage of internal shorthandoff variable from LaTeX writer
This commit is contained in:
Jean-François B 2018-06-08 20:30:15 +02:00 committed by GitHub
commit aedd79c7e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 17 deletions

View File

@ -82,6 +82,7 @@ Deprecated
* ``sphinx.writers.latex.LaTeXTranslator.push_hyperlink_ids()`` is deprecated
* ``sphinx.writers.latex.LaTeXTranslator.pop_hyperlink_ids()`` is deprecated
* ``sphinx.writers.latex.LaTeXTranslator.bibitems`` is deprecated
* ``sphinx.writers.latex.ExtBabel.get_shorthandoff()`` is deprecated
* ``sphinx.ext.mathbase.math`` node is deprecated
* ``sphinx.ext.mathbase.displaymath`` node is deprecated
* ``sphinx.ext.mathbase.eqref`` node is deprecated

View File

@ -216,6 +216,11 @@ The following is a list of deprecated interface.
- 3.0
- N/A
* - ``sphinx.writers.latex.ExtBabel.get_shorthandoff()``
- 1.8
- 3.0
- N/A
* - ``sphinx.application.CONFIG_FILENAME``
- 1.8
- 3.0

View File

@ -2119,7 +2119,6 @@ information.
``'author'``
``'logo'``
``'makeindex'``
``'shorthandoff'``
.. confval:: latex_docclass

View File

@ -49,6 +49,12 @@ BEGIN_DOC = r'''
%(tableofcontents)s
'''
SHORTHANDOFF = r'''
\ifdefined\shorthandoff
\ifnum\catcode`\=\string=\active\shorthandoff{=}\fi
\ifnum\catcode`\"=\active\shorthandoff{"}\fi
\fi
'''
MAX_CITATION_LABEL_LENGTH = 8
LATEXSECTIONNAMES = ["part", "chapter", "section", "subsection",
@ -199,16 +205,6 @@ class LaTeXWriter(writers.Writer):
class ExtBabel(Babel):
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
shorthands = {
'ngerman': '"',
'slovene': '"',
'portuges': '"',
'brazil': '"',
'spanish': '"',
'dutch': '"',
'polish': '"',
'italian': '"',
}
def __init__(self, language_code, use_polyglossia=False):
# type: (unicode, bool) -> None
@ -219,10 +215,9 @@ class ExtBabel(Babel):
def get_shorthandoff(self):
# type: () -> unicode
return ('\\ifdefined\\shorthandoff\n'
' \\ifnum\\catcode`\\=\\string=\\active\\shorthandoff{=}\\fi\n'
' \\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi\n'
'\\fi')
warnings.warn('ExtBabel.get_shorthandoff() is deprecated.',
RemovedInSphinx30Warning)
return SHORTHANDOFF
def uses_cyrillic(self):
# type: () -> bool
@ -579,7 +574,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
# this branch is not taken for xelatex/lualatex if default settings
self.elements['multilingual'] = self.elements['babel']
if builder.config.language:
self.elements['shorthandoff'] = self.babel.get_shorthandoff()
self.elements['shorthandoff'] = SHORTHANDOFF
# Times fonts don't work with Cyrillic languages
if self.babel.uses_cyrillic() \

View File

@ -467,7 +467,7 @@ def test_babel_with_language_ru(app, status, warning):
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
assert '\\shorthandoff' in result
assert '\\shorthandoff{"}' in result
@pytest.mark.sphinx(