|
From: <mi...@us...> - 2021-04-29 09:55:59
|
Revision: 8716
http://sourceforge.net/p/docutils/code/8716
Author: milde
Date: 2021-04-29 09:55:58 +0000 (Thu, 29 Apr 2021)
Log Message:
-----------
Fix "pseudoxml" writer option "detailled".
str.splitlines() does not allow keyword arguments under Python 2.7.
Add a test case.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_writers/test_pseudoxml.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2021-04-23 09:04:41 UTC (rev 8715)
+++ trunk/docutils/HISTORY.txt 2021-04-29 09:55:58 UTC (rev 8716)
@@ -16,6 +16,10 @@
Changes Since 0.17.1
====================
+* docutils/writers/pseudoxml.py:
+
+ - Fix option "detailled" under Python 2.7.
+
Release 0.17.1 (2021-04-16)
===========================
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2021-04-23 09:04:41 UTC (rev 8715)
+++ trunk/docutils/docutils/nodes.py 2021-04-29 09:55:58 UTC (rev 8716)
@@ -457,9 +457,9 @@
def pformat(self, indent=' ', level=0):
try:
if self.document.settings.detailled:
- lines = ['%s%s' % (indent * level, '<#text>')
- ] + [indent*(level+1) + repr(line)
- for line in self.splitlines(keepends=True)]
+ lines = ['%s%s' % (indent*level, '<#text>')
+ ] + [indent*(level+1) + repr(reprunicode(line))
+ for line in self.splitlines(True)]
return '\n'.join(lines) + '\n'
except AttributeError:
pass
Modified: trunk/docutils/test/test_writers/test_pseudoxml.py
===================================================================
--- trunk/docutils/test/test_writers/test_pseudoxml.py 2021-04-23 09:04:41 UTC (rev 8715)
+++ trunk/docutils/test/test_writers/test_pseudoxml.py 2021-04-29 09:55:58 UTC (rev 8716)
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# $Id$
+# $Id: test_pseudoxml.py 8481 2020-01-31 08:17:24Z milde $
# Author: Lea Wiemann <LeW...@gm...>
# Copyright: This module has been placed in the public domain.
@@ -15,20 +15,27 @@
def suite():
- s = DocutilsTestSupport.PublishTestSuite('pseudoxml')
+ # Settings dictionary must not be empty for later changes to work.
+ settings = {'expose_internals': []} # default
+ s = DocutilsTestSupport.PublishTestSuite('pseudoxml',
+ suite_settings=settings)
s.generateTests(totest)
+ settings['detailled'] = True
+ s.generateTests(totest_detailled)
return s
totest = {}
+totest_detailled = {}
totest['basic'] = [
# input
-["""\
+[r"""
This is a paragraph.
----------
-This is another paragraph.
+This is a paragraph
+with \escaped \characters.
A Section
---------
@@ -42,7 +49,8 @@
This is a paragraph.
<transition>
<paragraph>
- This is another paragraph.
+ This is a paragraph
+ with escaped characters.
<section ids="a-section" names="a\\ section">
<title>
A Section
@@ -51,6 +59,30 @@
"""]
]
+totest_detailled['basic'] = [
+# input
+[totest['basic'][0][0],
+# output
+"""\
+<document source="<string>">
+ <paragraph>
+ <#text>
+ 'This is a paragraph.'
+ <transition>
+ <paragraph>
+ <#text>
+ 'This is a paragraph\\n'
+ 'with \\x00escaped \\x00characters.'
+ <section ids="a-section" names="a\\ section">
+ <title>
+ <#text>
+ 'A Section'
+ <paragraph>
+ <#text>
+ 'Foo.'
+"""]
+]
+
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|