summaryrefslogtreecommitdiff
path: root/sphinx/builders/xml.py
diff options
context:
space:
mode:
authorJonathan Waltman <jonathan.waltman@gmail.com>2012-12-10 02:40:24 -0600
committerJonathan Waltman <jonathan.waltman@gmail.com>2012-12-10 02:40:24 -0600
commitf7afd0df761567f70fd04d9cf1ed8af74d3a2ac3 (patch)
tree35afd74508c04ecc7c7121bfc69627165fb7633f /sphinx/builders/xml.py
parent5818df7941b73abecdb1b399fee7956ea283d698 (diff)
downloadsphinx-f7afd0df761567f70fd04d9cf1ed8af74d3a2ac3.tar.gz
xml: Fix compatibility with docutils<0.9
Diffstat (limited to 'sphinx/builders/xml.py')
-rw-r--r--sphinx/builders/xml.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/sphinx/builders/xml.py b/sphinx/builders/xml.py
index 74c1fc06..6f0a5519 100644
--- a/sphinx/builders/xml.py
+++ b/sphinx/builders/xml.py
@@ -12,6 +12,7 @@
import codecs
from os import path
+from docutils import nodes
from docutils.io import StringOutput
from sphinx.builders import Builder
@@ -57,6 +58,18 @@ class XMLBuilder(Builder):
self.writer = self._writer_class(self)
def write_doc(self, docname, doctree):
+ # work around multiple string % tuple issues in docutils;
+ # replace tuples in attribute values with lists
+ doctree = doctree.deepcopy()
+ for node in doctree.traverse(nodes.Element):
+ for att, value in node.attributes.items():
+ if isinstance(value, tuple):
+ node.attributes[att] = list(value)
+ value = node.attributes[att]
+ if isinstance(value, list):
+ for i, val in enumerate(value):
+ if isinstance(val, tuple):
+ value[i] = list(val)
destination = StringOutput(encoding='utf-8')
self.writer.write(doctree, destination)
outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)