|
From: <mi...@us...> - 2012-02-08 19:46:20
|
Revision: 7348
http://docutils.svn.sourceforge.net/docutils/?rev=7348&view=rev
Author: milde
Date: 2012-02-08 19:46:11 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
Use `field_marker` pattern to look for start of a directive option block
(fixes [ 3484857 ]).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2012-02-06 21:03:50 UTC (rev 7347)
+++ trunk/docutils/HISTORY.txt 2012-02-08 19:46:11 UTC (rev 7348)
@@ -56,6 +56,8 @@
- Fix [ 3402314 ] allow non-ASCII whitespace, punctuation
characters and "international" quotes around inline markup.
+ - Use `field_marker` pattern to look for start of a
+ directive option block (fixes [ 3484857 ]).
* docutils/parsers/rst/tableparser.py
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2012-02-06 21:03:50 UTC (rev 7347)
+++ trunk/docutils/docutils/parsers/rst/states.py 2012-02-08 19:46:11 UTC (rev 7348)
@@ -2142,8 +2142,8 @@
def parse_directive_options(self, option_presets, option_spec, arg_block):
options = option_presets.copy()
- for i in range(len(arg_block)):
- if arg_block[i][:1] == ':':
+ for i, line in enumerate(arg_block):
+ if re.match(Body.patterns['field_marker'], line):
opt_block = arg_block[i:]
arg_block = arg_block[:i]
break
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2012-02-06 21:03:50 UTC (rev 7347)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2012-02-08 19:46:11 UTC (rev 7348)
@@ -111,6 +111,35 @@
No blank lines in-between.
"""],
["""\
+.. note:: Content before options
+ is possible too.
+ :class: mynote
+
+.. note:: :strong:`a role is not an option`.
+ :name: role not option
+
+.. note:: a role is
+ :strong:`not an option`, even if its starts a line.
+""",
+"""\
+<document source="test data">
+ <note classes="mynote">
+ <paragraph>
+ Content before options
+ is possible too.
+ <note ids="role-not-option" names="role\ not\ option">
+ <paragraph>
+ <strong>
+ a role is not an option
+ .
+ <note>
+ <paragraph>
+ a role is
+ <strong>
+ not an option
+ , even if its starts a line.
+"""],
+["""\
.. note::
""",
"""\
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 2012-02-06 21:03:50 UTC (rev 7347)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py 2012-02-08 19:46:11 UTC (rev 7348)
@@ -85,6 +85,8 @@
:width: 200
:scale: 50
"""],
+# If there are multiple lines in the link block, they are stripped of
+# leading and trailing whitespace and joined together:
["""\
.. image:: a/very/long/path/to/
picture.png
@@ -96,8 +98,36 @@
<document source="test data">
<image height="100" scale="50" uri="a/very/long/path/to/picture.png" width="200">
"""],
+# The following two misspellings were detected in Docutils <= 0.8
+# (the option block was started by any line starting with a colon
+# which led to problems with named roles in other directives):
["""\
.. image:: picture.png
+ :scale 50
+""",
+"""\
+<document source="test data">
+ <image uri="picture.png:scale50">
+"""],
+["""\
+.. image:: picture.png
+ :: 50
+""",
+"""\
+<document source="test data">
+ <image uri="picture.png::50">
+"""],
+# a missing leading colon went undetected also in Docutils <= 0.8:
+["""\
+.. image:: picture.png
+ scale: 50
+""",
+"""\
+<document source="test data">
+ <image uri="picture.pngscale:50">
+"""],
+["""\
+.. image:: picture.png
:width: 200px
:height: 100 em
""",
@@ -175,6 +205,7 @@
""" % DocutilsTestSupport.exception_data(int, None)[1][0]],
["""\
.. image:: picture.png
+ :height: 100
:scale 50
""",
"""\
@@ -185,32 +216,11 @@
invalid option block.
<literal_block xml:space="preserve">
.. image:: picture.png
+ :height: 100
:scale 50
"""],
["""\
.. image:: picture.png
- scale: 50
-""",
-"""\
-<document source="test data">
- <image uri="picture.pngscale:50">
-"""],
-["""\
-.. image:: picture.png
- :: 50
-""",
-"""\
-<document source="test data">
- <system_message level="3" line="1" source="test data" type="ERROR">
- <paragraph>
- Error in "image" directive:
- invalid option block.
- <literal_block xml:space="preserve">
- .. image:: picture.png
- :: 50
-"""],
-["""\
-.. image:: picture.png
:sale: 50
""",
"""\
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|