From c289a35c1b7dc4d259dbb0356758d37477727163 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 16 Apr 2016 18:28:15 +0900 Subject: [PATCH] Fix #2397: Setup shorthandoff for turkish documents --- CHANGES | 3 +++ sphinx/writers/latex.py | 2 ++ tests/test_build_latex.py | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/CHANGES b/CHANGES index a894b13085..39d32763dc 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,9 @@ Bugs fixed * #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart * #2407: building docs crash if document includes large data image URIs * #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed +* #2397: Setup shorthandoff for turkish documents + +Problems with pdflatex in a Turkish document built with sphinx #2397 Release 1.4.1 (released Apr 12, 2016) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 98a68d70d6..d08ab77a1e 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -127,6 +127,8 @@ class ExtBabel(Babel): 'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it', 'italian'): return '\\shorthandoff{"}' + elif shortlang in ('tr', 'turkish'): + return '\\shorthandoff{=}' return '' def uses_cyrillic(self): diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index e547ccb788..3da4f697d6 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -271,6 +271,7 @@ def test_babel_with_no_language_settings(app, status, warning): assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result + assert '\\shorthandoff' not in result @with_app(buildername='latex', testroot='latex-babel', @@ -290,6 +291,7 @@ def test_babel_with_language_de(app, status, warning): assert '\\addto\\captionsngerman{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsngerman{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\extrasngerman{\\def\\pageautorefname{page}}\n' in result + assert '\\shorthandoff{"}' in result @with_app(buildername='latex', testroot='latex-babel', @@ -309,6 +311,27 @@ def test_babel_with_language_ru(app, status, warning): assert '\\addto\\captionsrussian{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsrussian{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\extrasrussian{\\def\\pageautorefname{page}}\n' in result + assert '\\shorthandoff' not in result + + +@with_app(buildername='latex', testroot='latex-babel', + confoverrides={'language': 'tr'}) +def test_babel_with_language_tr(app, status, warning): + app.builder.build_all() + result = (app.outdir / 'Python.tex').text(encoding='utf8') + print(result) + print(status.getvalue()) + print(warning.getvalue()) + assert '\\documentclass[letterpaper,10pt,turkish]{sphinxmanual}' in result + assert '\\usepackage{babel}' in result + assert '\\usepackage{times}' in result + assert '\\usepackage[Sonny]{fncychap}' in result + assert ('\\addto\\captionsturkish{\\renewcommand{\\contentsname}{Table of content}}\n' + in result) + assert '\\addto\\captionsturkish{\\renewcommand{\\figurename}{Fig. }}\n' in result + assert '\\addto\\captionsturkish{\\renewcommand{\\tablename}{Table. }}\n' in result + assert '\\addto\\extrasturkish{\\def\\pageautorefname{sayfa}}\n' in result + assert '\\shorthandoff{=}' in result @with_app(buildername='latex', testroot='latex-babel', @@ -327,6 +350,7 @@ def test_babel_with_language_ja(app, status, warning): assert '\\renewcommand{\\figurename}{Fig. }\n' in result assert '\\renewcommand{\\tablename}{Table. }\n' in result assert u'\\def\\pageautorefname{ページ}\n' in result + assert '\\shorthandoff' not in result @with_app(buildername='latex', testroot='latex-babel', @@ -346,6 +370,7 @@ def test_babel_with_unknown_language(app, status, warning): assert '\\addto\\captionsenglish{\\renewcommand{\\figurename}{Fig. }}\n' in result assert '\\addto\\captionsenglish{\\renewcommand{\\tablename}{Table. }}\n' in result assert '\\addto\\extrasenglish{\\def\\pageautorefname{page}}\n' in result + assert '\\shorthandoff' not in result assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue()