From a695099a1bf48c817ad8a13a69bbdfb13d5bd21a Mon Sep 17 00:00:00 2001 From: jfbu Date: Tue, 30 Oct 2018 17:57:33 +0100 Subject: [PATCH 1/3] LaTeX: do not use `-I xelatex` option with xindy (Fix: #5561) It is not supported by old xindy (TeXLive 2013 or earlier), and probably irrelevant anyhow as the .idx file should not have ^^ab or ^^^^abcd entries. --- CHANGES | 1 + sphinx/texinputs/Makefile_t | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index d1a075373..f863f6461 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,7 @@ Bugs fixed * #5419: incompatible math_block node has been generated * #5548: Fix ensuredir() in case of pre-existing file * #5549: graphviz Correctly deal with non-existing static dir +* #5561: make all-pdf fails with old xindy version Testing -------- diff --git a/sphinx/texinputs/Makefile_t b/sphinx/texinputs/Makefile_t index 782d5ef9a..2afabb360 100644 --- a/sphinx/texinputs/Makefile_t +++ b/sphinx/texinputs/Makefile_t @@ -33,8 +33,6 @@ XINDYOPTS += -M LICRcyr2utf8.xdy {% if xindy_cyrillic -%} XINDYOPTS += -M LatinRules.xdy {% endif -%} -# also with pdflatex as LICRlatin2utf8.xdy replaces xindy's /tex/inputenc/utf8.xdy -XINDYOPTS += -I xelatex {% endif -%} # format: pdf or dvi (used only by archive targets) FMT = pdf From 021f370ade3c2f0c717f2e904c8ce019eadf7814 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 1 Nov 2018 00:46:19 +0900 Subject: [PATCH 2/3] Fix #5563: latex: footnote_references generated by extension causes LaTeX builder crashed --- CHANGES | 2 ++ sphinx/builders/latex/transforms.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index d1a075373..18600db7e 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,8 @@ Bugs fixed * #5419: incompatible math_block node has been generated * #5548: Fix ensuredir() in case of pre-existing file * #5549: graphviz Correctly deal with non-existing static dir +* #5563: latex: footnote_references generated by extension causes LaTeX builder + crashed Testing -------- diff --git a/sphinx/builders/latex/transforms.py b/sphinx/builders/latex/transforms.py index 160c8c324..3b2de2c1f 100644 --- a/sphinx/builders/latex/transforms.py +++ b/sphinx/builders/latex/transforms.py @@ -26,7 +26,7 @@ URI_SCHEMES = ('mailto:', 'http:', 'https:', 'ftp:') class FootnoteDocnameUpdater(SphinxTransform): """Add docname to footnote and footnote_reference nodes.""" - default_priority = 200 + default_priority = 700 TARGET_NODES = (nodes.footnote, nodes.footnote_reference) def apply(self): From e3574a6f78ebf524a343edd2951ff51665831853 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 30 Oct 2018 02:23:18 +0900 Subject: [PATCH 3/3] Fix #3002: i18n: multiple footnote_references referring same footnote causes duplicated node_ids --- CHANGES | 2 ++ sphinx/transforms/i18n.py | 14 +++++++------- tests/roots/test-intl/footnote.po | 6 ++++-- tests/roots/test-intl/footnote.txt | 1 + tests/test_intl.py | 10 +++++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index d1a075373..3cfb7947b 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,8 @@ Bugs fixed * #5419: incompatible math_block node has been generated * #5548: Fix ensuredir() in case of pre-existing file * #5549: graphviz Correctly deal with non-existing static dir +* #3002: i18n: multiple footnote_references referring same footnote causes + duplicated node_ids Testing -------- diff --git a/sphinx/transforms/i18n.py b/sphinx/transforms/i18n.py index f49e27df3..59a046628 100644 --- a/sphinx/transforms/i18n.py +++ b/sphinx/transforms/i18n.py @@ -364,7 +364,7 @@ class Locale(SphinxTransform): 'refname' in node old_foot_refs = node.traverse(is_refnamed_footnote_ref) new_foot_refs = patch.traverse(is_refnamed_footnote_ref) - refname_ids_map = {} + refname_ids_map = {} # type: Dict[unicode, List[unicode]] if len(old_foot_refs) != len(new_foot_refs): old_foot_ref_rawsources = [ref.rawsource for ref in old_foot_refs] new_foot_ref_rawsources = [ref.rawsource for ref in new_foot_refs] @@ -373,11 +373,11 @@ class Locale(SphinxTransform): .format(old_foot_ref_rawsources, new_foot_ref_rawsources), location=node) for old in old_foot_refs: - refname_ids_map[old["refname"]] = old["ids"] + refname_ids_map.setdefault(old["refname"], []).append(old["ids"]) for new in new_foot_refs: refname = new["refname"] - if refname in refname_ids_map: - new["ids"] = refname_ids_map[refname] + if refname_ids_map.get(refname): + new["ids"] = refname_ids_map[refname].pop(0) # citation should use original 'ids'. def is_citation_ref(node): @@ -395,11 +395,11 @@ class Locale(SphinxTransform): .format(old_cite_ref_rawsources, new_cite_ref_rawsources), location=node) for old in old_cite_refs: - refname_ids_map[old["refname"]] = old["ids"] + refname_ids_map.setdefault(old["refname"], []).append(old["ids"]) for new in new_cite_refs: refname = new["refname"] - if refname in refname_ids_map: - new["ids"] = refname_ids_map[refname] + if refname_ids_map.get(refname): + new["ids"] = refname_ids_map[refname].pop() # Original pending_xref['reftarget'] contain not-translated # target name, new pending_xref must use original one. diff --git a/tests/roots/test-intl/footnote.po b/tests/roots/test-intl/footnote.po index 1dd6b93a7..869bf62fe 100644 --- a/tests/roots/test-intl/footnote.po +++ b/tests/roots/test-intl/footnote.po @@ -19,8 +19,10 @@ msgstr "" msgid "i18n with Footnote" msgstr "I18N WITH FOOTNOTE" -msgid "[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ [#named]_ [*]_." -msgstr "`I18N WITH FOOTNOTE`_ INCLUDE THIS CONTENTS [#named]_ [ref]_ [#]_ [100]_ [*]_." +msgid "[100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ [#named]_ [*]_. " +"second footnote_ref [100]_." +msgstr "`I18N WITH FOOTNOTE`_ INCLUDE THIS CONTENTS [#named]_ [ref]_ [#]_ [100]_ [*]_. " +"SECOND FOOTNOTE_REF [100]_." msgid "This is a auto numbered footnote." msgstr "THIS IS A AUTO NUMBERED FOOTNOTE." diff --git a/tests/roots/test-intl/footnote.txt b/tests/roots/test-intl/footnote.txt index 04639fa01..0bbed9145 100644 --- a/tests/roots/test-intl/footnote.txt +++ b/tests/roots/test-intl/footnote.txt @@ -5,6 +5,7 @@ i18n with Footnote .. #955 cant-build-html-with-footnotes-when-using [100]_ Contents [#]_ for `i18n with Footnote`_ [ref]_ [#named]_ [*]_. +second footnote_ref [100]_. .. [#] This is a auto numbered footnote. .. [ref] This is a named footnote. diff --git a/tests/test_intl.py b/tests/test_intl.py index c8f90e41c..aed323eed 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -794,9 +794,13 @@ def test_xml_footnotes(app, warning): assert_elem( para0[0], ['I18N WITH FOOTNOTE', 'INCLUDE THIS CONTENTS', - '2', '[ref]', '1', '100', '*', '.'], + '2', '[ref]', '1', '100', '*', '. SECOND FOOTNOTE_REF', '100', '.'], ['i18n-with-footnote', 'ref']) + # check node_id for footnote_references which refer same footnote (refs: #3002) + assert para0[0][4].text == para0[0][6].text == '100' + assert para0[0][4].attrib['ids'] != para0[0][6].attrib['ids'] + footnote0 = secs[0].findall('footnote') assert_elem( footnote0[0], @@ -848,8 +852,8 @@ def test_xml_footnote_backlinks(app): footnote0 = secs[0].findall('footnote') for footnote in footnote0: ids = footnote.attrib.get('ids') - backrefs = footnote.attrib.get('backrefs') - assert refid2id[ids] == backrefs + backrefs = footnote.attrib.get('backrefs').split() + assert refid2id[ids] in backrefs @sphinx_intl