diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2020-10-28 08:46:19 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2020-10-28 08:46:19 +0000 |
| commit | f10cbc9df322a90d2bc53580f2eedccab164a52f (patch) | |
| tree | fff2419e563d12957174337fe7c255845269ec4e /docutils | |
| parent | 331edb3e115226903c6db700f705128a2c05af00 (diff) | |
| download | docutils-f10cbc9df322a90d2bc53580f2eedccab164a52f.tar.gz | |
Apply patch #174 Lowercase new role names on registration
and document that role names are case insensitive.
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8571 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
| -rw-r--r-- | docutils/HISTORY.txt | 8 | ||||
| -rw-r--r-- | docutils/docs/ref/rst/directives.txt | 11 | ||||
| -rw-r--r-- | docutils/docs/ref/rst/restructuredtext.txt | 6 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/roles.py | 4 | ||||
| -rwxr-xr-x | docutils/test/test_parsers/test_rst/test_directives/test_role.py | 13 |
5 files changed, 34 insertions, 8 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 864847fae..c885777cd 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -41,14 +41,18 @@ Changes Since 0.16 - 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. diff --git a/docutils/docs/ref/rst/directives.txt b/docutils/docs/ref/rst/directives.txt index 146450605..7ff8717d2 100644 --- a/docutils/docs/ref/rst/directives.txt +++ b/docutils/docs/ref/rst/directives.txt @@ -1775,7 +1775,7 @@ Custom Interpreted Text Roles :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 @@ This will be parsed into the following document tree fragment:: 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 @@ _`:name:` : text 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 diff --git a/docutils/docs/ref/rst/restructuredtext.txt b/docutils/docs/ref/rst/restructuredtext.txt index bfb0a4f89..a350ef090 100644 --- a/docutils/docs/ref/rst/restructuredtext.txt +++ b/docutils/docs/ref/rst/restructuredtext.txt @@ -372,6 +372,7 @@ appear in Python docstrings is to use raw docstrings:: r"""This is a raw docstring. Backslashes (\) are not touched.""" +.. _reference name: Reference Names =============== @@ -2669,7 +2670,8 @@ Interpreted text allows extensions to the available inline descriptive 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 @@ by a trailing underscore. Footnote labels are one of: - 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`_). diff --git a/docutils/docutils/parsers/rst/roles.py b/docutils/docutils/parsers/rst/roles.py index 677e2f015..1dd395077 100644 --- a/docutils/docutils/parsers/rst/roles.py +++ b/docutils/docutils/parsers/rst/roles.py @@ -152,7 +152,7 @@ def register_canonical_role(name, role_fn): - `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 @@ def register_local_role(name, role_fn): - `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): """ diff --git a/docutils/test/test_parsers/test_rst/test_directives/test_role.py b/docutils/test/test_parsers/test_rst/test_directives/test_role.py index b1b8c130f..f5d6aa26b 100755 --- a/docutils/test/test_parsers/test_rst/test_directives/test_role.py +++ b/docutils/test/test_parsers/test_rst/test_directives/test_role.py @@ -212,6 +212,19 @@ Empty :custom:`\\ ` and empty `\\ `:special: 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'] = [ |
