This module defines standard interpreted text role functions, a registry for interpreted text roles, and an API for adding to and retrieving from the registry.
The interface for interpreted role functions is as follows:
def role_fn(name, rawtext, text, lineno, inliner, options={}, content=[]): code... # Set function attributes for customization: role_fn.options = ... role_fn.content = ...
Parameters:
Function attributes for customization, interpreted by the "role" directive:
options: A dictionary, mapping known option names to conversion
functions such as int
or float
. None or an empty dict implies no
options to parse. Several directive option conversion functions are defined
in the directives
module.
All role functions implicitly support the "class" option, unless disabled with an explicit {'class': None}.
content: A boolean; true if content is allowed. Client code must handle the case where content is required but not supplied (an empty content list will be supplied).
Note that unlike directives, the "arguments" function attribute is not supported for role customization. Directive arguments are handled by the "role" directive itself.
Interpreted role functions return a tuple of two values:
Class | CustomRole |
Wrapper for custom interpreted text roles. |
Class | GenericRole |
Generic interpreted text role, where the interpreted text is simply wrapped with the provided node class. |
Function | code_role |
Undocumented |
Function | generic_custom_role |
Undocumented |
Function | math_role |
Undocumented |
Function | pep_reference_role |
Undocumented |
Function | raw_role |
Undocumented |
Function | register_canonical_role |
Register an interpreted text role by its canonical name. |
Function | register_generic_role |
For roles which simply wrap a given node_class around the text. |
Function | register_local_role |
Register an interpreted text role by its local or language-dependent name. |
Function | rfc_reference_role |
Undocumented |
Function | role |
No summary |
Function | set_classes |
Auxiliary function to set options['classes'] and delete options['class']. |
Function | set_implicit_options |
Add customization options to role functions, unless explicitly set or disabled. |
Function | unimplemented_role |
Undocumented |
Constant | DEFAULT_INTERPRETED_ROLE |
The canonical name of the default interpreted role. This role is used when no role is specified for a piece of interpreted text. |
Variable | _role_registry |
Mapping of canonical role names to role functions. Language-dependent role names are defined in the language subpackage. |
Variable | _roles |
Mapping of local or language-dependent interpreted text role names to role functions. |
Parameters | |
name | The canonical name of the interpreted role. |
role_fn | The role function. See the module docstring. |
Parameters | |
name | The local or language-dependent name of the interpreted role. |
role_fn | The role function. See the module docstring. |
Value |
|