Source: sphinx
Version: 1.1.3+dfsg-4
Severity: normal
Tags: patch
Control: affects -1 ubuntu-packaging-guide

Dear maintainer,

The attached patch is a cherry-pick of upstream changeset that fixes
build of localized projects that contain footnotes in the text.

It affects the ubuntu-packaging-guide package (yes, a package in Debian)
which is going to ship translation packages.

It is not urgent, but it would be very good if this patch is applied in
(at least experimental version of) sphinx.

Please let me know if I should go ahead and commit it myself.

--
Dmitry Shachnev

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (700, 'unstable'), (500, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/4 CPU cores)
Locale: LANG=ru_RU.utf8, LC_CTYPE=ru_RU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Description: Only update text nodes in translation
 This fixes build of documents with footnotes when localization is enabled.
Origin: upstream, https://bitbucket.org/birkenfeld/sphinx/changeset/b7b808e46851
Bug: https://bitbucket.org/birkenfeld/sphinx/issue/955/cant-build-html-with-footnotes-when-using
Author: Christophe Simonis <simonis.christo...@gmail.com>
Last-Update: 2012-10-29

diff -r 1f3a2749df39 sphinx/environment.py
--- a/sphinx/environment.py	Sun Jul 29 19:27:36 2012 +0200
+++ b/sphinx/environment.py	Tue Oct 09 23:41:21 2012 +0200
@@ -213,19 +213,23 @@
         parser = RSTParser()
 
         for node, msg in extract_messages(self.document):
-            patch = new_document(source, settings)
             msgstr = catalog.gettext(msg)
             # XXX add marker to untranslated parts
             if not msgstr or msgstr == msg: # as-of-yet untranslated
                 continue
+
+            patch = new_document(source, settings)
             parser.parse(msgstr, patch)
             patch = patch[0]
             # XXX doctest and other block markup
             if not isinstance(patch, nodes.paragraph):
                 continue # skip for now
-            for child in patch.children: # update leaves
-                child.parent = node
-            node.children = patch.children
+
+            # copy text children
+            for i, child in enumerate(patch.children):
+                if isinstance(child, nodes.Text):
+                    child.parent = node
+                    node.children[i] = child
 
 
 class SphinxStandaloneReader(standalone.Reader):

Reply via email to