mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove usage of internal shorthandoff variable from LaTeX writer
This commit is contained in:
parent
f9e2a41a48
commit
a32c358342
@ -2114,7 +2114,6 @@ information.
|
|||||||
``'author'``
|
``'author'``
|
||||||
``'logo'``
|
``'logo'``
|
||||||
``'makeindex'``
|
``'makeindex'``
|
||||||
``'shorthandoff'``
|
|
||||||
|
|
||||||
.. confval:: latex_docclass
|
.. confval:: latex_docclass
|
||||||
|
|
||||||
|
@ -44,7 +44,10 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
BEGIN_DOC = r'''
|
BEGIN_DOC = r'''
|
||||||
\begin{document}
|
\begin{document}
|
||||||
%(shorthandoff)s
|
\ifdefined\shorthandoff
|
||||||
|
\ifnum\catcode`\=\string=\active\shorthandoff{=}\fi
|
||||||
|
\ifnum\catcode`\"=\active\shorthandoff{"}\fi
|
||||||
|
\fi
|
||||||
%(maketitle)s
|
%(maketitle)s
|
||||||
%(tableofcontents)s
|
%(tableofcontents)s
|
||||||
'''
|
'''
|
||||||
@ -101,7 +104,6 @@ DEFAULT_SETTINGS = {
|
|||||||
'logo': '\\vbox{}',
|
'logo': '\\vbox{}',
|
||||||
'releasename': '',
|
'releasename': '',
|
||||||
'makeindex': '\\makeindex',
|
'makeindex': '\\makeindex',
|
||||||
'shorthandoff': '',
|
|
||||||
'maketitle': '\\maketitle',
|
'maketitle': '\\maketitle',
|
||||||
'tableofcontents': '\\sphinxtableofcontents',
|
'tableofcontents': '\\sphinxtableofcontents',
|
||||||
'atendofbody': '',
|
'atendofbody': '',
|
||||||
@ -217,13 +219,6 @@ class ExtBabel(Babel):
|
|||||||
self.supported = True
|
self.supported = True
|
||||||
super(ExtBabel, self).__init__(language_code or '')
|
super(ExtBabel, self).__init__(language_code or '')
|
||||||
|
|
||||||
def get_shorthandoff(self):
|
|
||||||
# type: () -> unicode
|
|
||||||
return ('\\ifdefined\\shorthandoff\n'
|
|
||||||
' \\ifnum\\catcode`\\=\\string=\\active\\shorthandoff{=}\\fi\n'
|
|
||||||
' \\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi\n'
|
|
||||||
'\\fi')
|
|
||||||
|
|
||||||
def uses_cyrillic(self):
|
def uses_cyrillic(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
return self.language in self.cyrillic_languages
|
return self.language in self.cyrillic_languages
|
||||||
@ -579,7 +574,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# this branch is not taken for xelatex/lualatex if default settings
|
# this branch is not taken for xelatex/lualatex if default settings
|
||||||
self.elements['multilingual'] = self.elements['babel']
|
self.elements['multilingual'] = self.elements['babel']
|
||||||
if builder.config.language:
|
if builder.config.language:
|
||||||
self.elements['shorthandoff'] = self.babel.get_shorthandoff()
|
|
||||||
|
|
||||||
# Times fonts don't work with Cyrillic languages
|
# Times fonts don't work with Cyrillic languages
|
||||||
if self.babel.uses_cyrillic() \
|
if self.babel.uses_cyrillic() \
|
||||||
@ -592,7 +586,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
self.elements['classoptions'] = ',dvipdfmx'
|
self.elements['classoptions'] = ',dvipdfmx'
|
||||||
# disable babel which has not publishing quality in Japanese
|
# disable babel which has not publishing quality in Japanese
|
||||||
self.elements['babel'] = ''
|
self.elements['babel'] = ''
|
||||||
self.elements['shorthandoff'] = ''
|
|
||||||
self.elements['multilingual'] = ''
|
self.elements['multilingual'] = ''
|
||||||
# disable fncychap in Japanese documents
|
# disable fncychap in Japanese documents
|
||||||
self.elements['fncychap'] = ''
|
self.elements['fncychap'] = ''
|
||||||
|
@ -424,7 +424,6 @@ def test_babel_with_no_language_settings(app, status, warning):
|
|||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
||||||
assert '\\shorthandoff' not in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -445,7 +444,6 @@ def test_babel_with_language_de(app, status, warning):
|
|||||||
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasngerman{\\def\\pageautorefname{Seite}}\n' in result
|
assert '\\addto\\extrasngerman{\\def\\pageautorefname{Seite}}\n' in result
|
||||||
assert '\\shorthandoff{"}' in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -467,7 +465,6 @@ def test_babel_with_language_ru(app, status, warning):
|
|||||||
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
|
assert (u'\\addto\\extrasrussian{\\def\\pageautorefname'
|
||||||
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
|
u'{\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430}}\n' in result)
|
||||||
assert '\\shorthandoff' in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -488,7 +485,6 @@ def test_babel_with_language_tr(app, status, warning):
|
|||||||
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
|
assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result
|
||||||
assert '\\shorthandoff{=}' in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -508,7 +504,6 @@ def test_babel_with_language_ja(app, status, warning):
|
|||||||
assert '\\renewcommand{\\figurename}{Fig.}\n' in result
|
assert '\\renewcommand{\\figurename}{Fig.}\n' in result
|
||||||
assert '\\renewcommand{\\tablename}{Table.}\n' in result
|
assert '\\renewcommand{\\tablename}{Table.}\n' in result
|
||||||
assert u'\\def\\pageautorefname{ページ}\n' in result
|
assert u'\\def\\pageautorefname{ページ}\n' in result
|
||||||
assert '\\shorthandoff' not in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -529,7 +524,6 @@ def test_babel_with_unknown_language(app, status, warning):
|
|||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result
|
||||||
assert '\\shorthandoff' in result
|
|
||||||
|
|
||||||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()
|
||||||
|
|
||||||
@ -553,7 +547,6 @@ def test_polyglossia_with_language_de(app, status, warning):
|
|||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\def\\pageautorefname{Seite}\n' in result
|
assert '\\def\\pageautorefname{Seite}\n' in result
|
||||||
assert '\\shorthandoff' not in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx(
|
@pytest.mark.sphinx(
|
||||||
@ -575,7 +568,6 @@ def test_polyglossia_with_language_de_1901(app, status, warning):
|
|||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\figurename}{Fig.}}\n' in result
|
||||||
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
assert '\\addto\\captionsgerman{\\renewcommand{\\tablename}{Table.}}\n' in result
|
||||||
assert '\\def\\pageautorefname{page}\n' in result
|
assert '\\def\\pageautorefname{page}\n' in result
|
||||||
assert '\\shorthandoff' not in result
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('latex')
|
@pytest.mark.sphinx('latex')
|
||||||
|
Loading…
Reference in New Issue
Block a user