|
From: <go...@us...> - 2017-02-06 00:41:51
|
Revision: 8024
http://sourceforge.net/p/docutils/code/8024
Author: goodger
Date: 2017-02-06 00:41:48 +0000 (Mon, 06 Feb 2017)
Log Message:
-----------
Added support for escaped whitespace in URI contexts
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-02-05 10:29:18 UTC (rev 8023)
+++ trunk/docutils/HISTORY.txt 2017-02-06 00:41:48 UTC (rev 8024)
@@ -28,6 +28,10 @@
- Recognize non-ASCII whitespace around inline literal, target,
and substitution.
+* docutils/parsers/rst/directives/images.py:
+
+ - Added support for escaped whitespace in URI contexts.
+
* docutils/parsers/rst/directives/tables.py:
- Rework patch [ 120 ] (revert change to ``Table.get_column_widths()``
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2017-02-05 10:29:18 UTC (rev 8023)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2017-02-06 00:41:48 UTC (rev 8024)
@@ -13,6 +13,7 @@
import sys
from docutils import nodes
+from docutils.utils import split_escaped_whitespace, escape2null, unescape
from docutils.parsers.rst.languages import en as _fallback_language_module
if sys.version_info < (2,5):
from docutils._compat import __import__
@@ -189,7 +190,7 @@
def uri(argument):
"""
- Return the URI argument with whitespace removed.
+ Return the URI argument with unescaped whitespace removed.
(Directive option conversion function.)
Raise ``ValueError`` if no argument is found.
@@ -197,7 +198,8 @@
if argument is None:
raise ValueError('argument required but none supplied')
else:
- uri = ''.join(argument.split())
+ parts = split_escaped_whitespace(escape2null(argument))
+ uri = ' '.join(''.join(unescape(part).split()) for part in parts)
return uri
def nonnegative_int(argument):
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py 2017-02-05 10:29:18 UTC (rev 8023)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py 2017-02-06 00:41:48 UTC (rev 8024)
@@ -432,6 +432,16 @@
<image uri="test.png">
<target ids="uppercase" names="uppercase" refuri="http://docutils.sourceforge.net/">
"""],
+[r"""
+.. image:: path\ with\ spaces/name\ with\ spaces.png
+ :target: path\ with\ spaces/
+ target\ with\ spaces\ across\ lines.html
+""",
+"""\
+<document source="test data">
+ <reference refuri="path with spaces/target with spaces across lines.html">
+ <image uri="path with spaces/name with spaces.png">
+"""],
]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|