Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev-python/sphinx: add upstream commit for better language support
Package-Manager: Portage-2.3.40, Repoman-2.3.9
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
From 24cecfd0bc4bc3e9910d09e8bd1326cbff41e525 Mon Sep 17 00:00:00 2001 | ||
From: jfbu <jfbu@free.fr> | ||
Date: Tue, 5 Jun 2018 09:56:36 +0200 | ||
Subject: [PATCH 1/2] LaTeX: update list of language codes with " active | ||
|
||
cf docutils.writers.latex2e and LaTeX babel package main documentation, | ||
section \babelshorthand which gives a list of shorthands used per | ||
language. | ||
--- | ||
sphinx/writers/latex.py | 33 ++++++++++++++++++++++++++++++--- | ||
1 file changed, 30 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py | ||
index bd88ca842..84c80ccda 100644 | ||
--- a/sphinx/writers/latex.py | ||
+++ b/sphinx/writers/latex.py | ||
@@ -200,15 +200,10 @@ def __init__(self, language_code, use_polyglossia=False): | ||
|
||
def get_shorthandoff(self): | ||
# type: () -> unicode | ||
- shortlang = self.language.split('_')[0] | ||
- if shortlang in ('de', 'ngerman', 'sl', 'slovene', 'pt', 'portuges', | ||
- 'es', 'spanish', 'nl', 'dutch', 'pl', 'polish', 'it', | ||
- 'italian', 'pt-BR', 'brazil'): | ||
- return '\\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi' | ||
- elif shortlang in ('tr', 'turkish'): | ||
- # memo: if ever Sphinx starts supporting 'Latin', do as for Turkish | ||
- return '\\ifnum\\catcode`\\=\\string=\\active\\shorthandoff{=}\\fi' | ||
- return '' | ||
+ return ('\\ifdefined\\shorthandoff\n' | ||
+ ' \\ifnum\\catcode`\\=\\string=\\active\\shorthandoff{=}\\fi\n' | ||
+ ' \\ifnum\\catcode`\\"=\\active\\shorthandoff{"}\\fi\n' | ||
+ '\\fi') | ||
|
||
def uses_cyrillic(self): | ||
# type: () -> bool | ||
@@ -568,6 +563,7 @@ def __init__(self, document, builder): | ||
self.elements['classoptions'] = ',dvipdfmx' | ||
# disable babel which has not publishing quality in Japanese | ||
self.elements['babel'] = '' | ||
+ self.elements['shorthandoff'] = '' | ||
self.elements['multilingual'] = '' | ||
# disable fncychap in Japanese documents | ||
self.elements['fncychap'] = '' | ||
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py | ||
index 96ae14089..68704d9a3 100644 | ||
--- a/tests/test_build_latex.py | ||
+++ b/tests/test_build_latex.py | ||
@@ -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' not in result | ||
+ assert '\\shorthandoff' in result | ||
|
||
|
||
@pytest.mark.sphinx( | ||
@@ -529,7 +529,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 '\\shorthandoff' in result | ||
|
||
assert "WARNING: no Babel option known for language 'unknown'" in warning.getvalue() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters