From f4c58d46a7b5f8bf71a032760cb5e84fb6c7d13c Mon Sep 17 00:00:00 2001 From: milde Date: Thu, 24 Nov 2011 08:59:47 +0000 Subject: [PATCH] Fix 3423983 DocutilsXMLTestCase with indent and newlines options Add sample strings with the new XML formatting introduced in versions 2.7.3 and 3.2.3 on 2011-11-18 to fix http://bugs.python.org/issue4147 git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7226 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- docs/user/config.txt | 15 ++++++++++----- docutils/writers/docutils_xml.py | 5 +++-- test/test_writers/test_docutils_xml.py | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/docs/user/config.txt b/docs/user/config.txt index 82e073645..e8167d21d 100644 --- a/docs/user/config.txt +++ b/docs/user/config.txt @@ -459,7 +459,7 @@ _`strip_comments` ``--leave-comments``. _`strip_elements_with_classes` - Comma-separated list of "classes" attribute values; + Comma-separated list of "classes" attribute values; matching elements are removed from the document tree. The command line option may be used more than once. @@ -647,6 +647,15 @@ Under construction. [docutils_xml writer] ````````````````````` +.. Caution:: + + * In versions older than 2.7.3 and 3.2.3, the newlines_ and indents_ + options may adversely affect whitespace; use them only for reading + convenience (see http://bugs.python.org/issue4147). + + * The XML declaration carries text encoding information, without which + standard tools may be unable to read the generated XML. + _`doctype_declaration` Generate XML with a DOCTYPE declaration. @@ -668,10 +677,6 @@ xml_declaration Generate XML with an XML declaration. Also defined for the `HTML Writer`__. - .. Caution:: The XML declaration carries text encoding - information, without which standard tools may be unable to read - the generated XML. - Default: do (1). Options: ``--no-xml-declaration``. __ `xml_declaration [html4css1 writer]`_ diff --git a/docutils/writers/docutils_xml.py b/docutils/writers/docutils_xml.py index 73bba6782..d7c870dc8 100644 --- a/docutils/writers/docutils_xml.py +++ b/docutils/writers/docutils_xml.py @@ -20,8 +20,9 @@ class Writer(writers.Writer): settings_spec = ( '"Docutils XML" Writer Options', - 'Warning: the --newlines and --indents options may adversely affect ' - 'whitespace; use them only for reading convenience.', + 'Warning: In versions older than 2.7.3 and 3.2.3, the --newlines and ' + '--indents options may adversely affect whitespace; use them only ' + 'for reading convenience (see http://bugs.python.org/issue4147).', (('Generate XML with newlines before and after tags.', ['--newlines'], {'action': 'store_true', 'validator': frontend.validate_boolean}), diff --git a/test/test_writers/test_docutils_xml.py b/test/test_writers/test_docutils_xml.py index 8ec204f16..78a2c00d2 100755 --- a/test/test_writers/test_docutils_xml.py +++ b/test/test_writers/test_docutils_xml.py @@ -10,6 +10,7 @@ Test for docutils XML writer. from __init__ import DocutilsTestSupport +import sys import docutils import docutils.core @@ -40,6 +41,14 @@ bodynormal = u"""\ bodynewlines = u"""\ +Test + +Test. \xe4\xf6\xfc€ + +""" + +bodynewlines_old = u"""\ + Test @@ -52,6 +61,14 @@ Test. \xe4\xf6\xfc€ bodyindents = u"""\ + Test + + Test. \xe4\xf6\xfc€ + +""" + +bodyindents_old = u"""\ + Test @@ -62,6 +79,13 @@ bodyindents = u"""\ """ +# New formatting introduced in versions 2.7.3 and 3.2.3 on 2011-11-18 +# to fix http://bugs.python.org/issue4147 +if (sys.version_info < (2, 7, 3) or + sys.version_info[0] == 3 and sys.version_info < (3, 2, 3)): + bodynewlines = bodynewlines_old + bodyindents = bodyindents_old + class DocutilsXMLTestCase(DocutilsTestSupport.StandardTestCase): -- 2.11.4.GIT