|
From: <mi...@us...> - 2020-10-28 08:46:23
|
Revision: 8571
http://sourceforge.net/p/docutils/code/8571
Author: milde
Date: 2020-10-28 08:46:19 +0000 (Wed, 28 Oct 2020)
Log Message:
-----------
Apply patch #174 Lowercase new role names on registration
and document that role names are case insensitive.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/HISTORY.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -41,14 +41,18 @@
- Apply version of patch #167: Let document.set_id() register all
existing IDs (thanks to Takeshi KOMIYA).
-* docutils/parsers/rst/directives/body.py:
+* docutils/parsers/rst/directives/body.py
- Make the sidebar's "title" argument optional (feature request #69).
-* docutils/parsers/rst/directives/misc.py:
+* docutils/parsers/rst/directives/misc.py
- Prevent infinite inclusion loops.
+* docutils/parsers/rst/roles.py
+
+ - Apply patch #174 Lowercase new role names on registration
+
* docutils/utils/smartquotes.py
- Fix bug #383: Smart quotes around opening and separator characters.
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docs/ref/rst/directives.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -1775,7 +1775,7 @@
:Directive Type: "role"
:Doctree Element: None; affects subsequent parsing.
-:Directive Arguments: Two; one required (new role name), one optional
+:Directive Arguments: Two; one required (new `role name`_), one optional
(base role name, in parentheses).
:Directive Options: Possible (depends on base role).
:Directive Content: depends on base role.
@@ -1801,6 +1801,12 @@
The role must be declared in a document before it can be used.
+.. _role name:
+
+Role names are case insensitive and must conform to the rules of
+simple `reference names`_ (but do not share a namespace with
+hyperlinks, footnotes, and citations).
+
The new role may be based on an existing role, specified as a second
argument in parentheses (whitespace optional)::
@@ -1966,7 +1972,8 @@
New in Docutils 0.8.
-.. _reference name: restructuredtext.html#reference-names
+.. _reference name:
+.. _reference names: restructuredtext.html#reference-names
.. _hyperlink target: restructuredtext.html#hyperlink-targets
.. _hyperlink references: restructuredtext.html#hyperlink-references
.. _class names: ../doctree.html#classnames-type
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2020-10-28 08:46:19 UTC (rev 8571)
@@ -372,6 +372,7 @@
r"""This is a raw docstring. Backslashes (\) are not touched."""
+.. _reference name:
Reference Names
===============
@@ -2669,7 +2670,8 @@
markup constructs. To emphasis_, `strong emphasis`_, `inline
literals`_, and `hyperlink references`_, we can add "title reference",
"index entry", "acronym", "class", "red", "blinking" or anything else
-we want. Only pre-determined roles are recognized; unknown roles will
+we want (as long as it is a simple `reference name`_).
+Only pre-determined roles are recognized; unknown roles will
generate errors. A core set of standard roles is implemented in the
reference parser; see `reStructuredText Interpreted Text Roles`_ for
individual descriptions. The role_ directive can be used to define
@@ -2888,7 +2890,7 @@
- a single "#" (denoting `auto-numbered footnotes`_),
-- a "#" followed by a simple reference name (an `autonumber label`_),
+- a "#" followed by a simple `reference name`_ (an `autonumber label`_),
or
- a single "*" (denoting `auto-symbol footnotes`_).
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2020-10-28 08:46:19 UTC (rev 8571)
@@ -152,7 +152,7 @@
- `role_fn`: The role function. See the module docstring.
"""
set_implicit_options(role_fn)
- _role_registry[name] = role_fn
+ _role_registry[name.lower()] = role_fn
def register_local_role(name, role_fn):
"""
@@ -163,7 +163,7 @@
- `role_fn`: The role function. See the module docstring.
"""
set_implicit_options(role_fn)
- _roles[name] = role_fn
+ _roles[name.lower()] = role_fn
def set_implicit_options(role_fn):
"""
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2020-10-28 07:03:30 UTC (rev 8570)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2020-10-28 08:46:19 UTC (rev 8571)
@@ -212,6 +212,19 @@
and empty
<inline classes="special">
"""],
+["""\
+.. role:: CaSiNg
+
+Role names are :cAsInG:`case-insensitive`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Role names are \n\
+ <inline classes="casing">
+ case-insensitive
+ .
+"""],
]
totest['raw_role'] = [
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|