Skip to content

Commit

Permalink
dev-python/sphinx: add upstream commit for better language support
Browse files Browse the repository at this point in the history
Package-Manager: Portage-2.3.40, Repoman-2.3.9
  • Loading branch information
kiwifb committed Jun 10, 2018
1 parent 67316dc commit 409a262
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
66 changes: 66 additions & 0 deletions dev-python/sphinx/files/PR5040.patch
@@ -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()

Expand Up @@ -56,6 +56,10 @@ DEPEND="${RDEPEND}
virtual/python-enum34[${PYTHON_USEDEP}]
)"

PATCHES=(
"${FILESDIR}"/PR5040.patch
)

S="${WORKDIR}/${P^}"

python_prepare_all() {
Expand Down

0 comments on commit 409a262

Please sign in to comment.