File: //usr/lib/python3/dist-packages/docutils/parsers/rst/__pycache__/roles.cpython-310.pyc
o
n��_p: � @ s d Z dZddlmZmZ ddlmZ ddlmZ ddl
mZmZ dZ
i Z i Z dd � Zd
d� Zdd
� Zdd� Zdd� ZG dd� de�ZG dd� de�Zi g fdd�Zdejie_edej� edej� edej� edej� edej� edej � edej!� edej"� i g fd d!�Z#ed"e#� i g fd#d$�Z$ed%e$� i g fd&d'�Z%d(ej&ie%_ed)e%� i g fd*d+�Z'ejej&d,�e'_ed-e'� i g fd.d/�Z(ed0e(� i fd1d2�Z)ed3e)� ed4e)� ed5e)� ed6e)� ed7e)� ed8e)� ed9e)� ed:e)� ed;e)� d<d=� Z*d>S )?a
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:
- ``name`` is the local name of the interpreted text role, the role name
actually used in the document.
- ``rawtext`` is a string containing the entire interpreted text construct.
Return it as a ``problematic`` node linked to a system message if there is a
problem.
- ``text`` is the interpreted text content, with backslash escapes converted
to nulls (`` ``).
- ``lineno`` is the line number where the interpreted text beings.
- ``inliner`` is the Inliner object that called the role function.
It defines the following useful attributes: ``reporter``,
``problematic``, ``memo``, ``parent``, ``document``.
- ``options``: A dictionary of directive options for customization, to be
interpreted by the role function. Used for additional attributes for the
generated elements and other functionality.
- ``content``: A list of strings, the directive content for customization
("role" directive). To be interpreted by the role function.
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:
- A list of nodes which will be inserted into the document tree at the
point where the interpreted role was encountered (can be an empty
list).
- A list of system messages, which will be inserted into the document tree
immediately after the end of the current inline block (can also be empty).
�reStructuredText� )�nodes�utils)�
directives)�en)�Lexer�
LexerErrorztitle-referencec
C s, | � � }g }g }|tv rt| |fS | rKd}z|j| }W n/ ty8 } z|�d||f � W Y d}~nd}~w tyJ |�d| |jf � Y nw t}|spztj| }|�d| � W n tyo |�d| � |}Y nw |r�|j d�
|�|d�} |�| � |tv r�t| }
t||
� |
|fS d|fS )a.
Locate and return a role function from its language-dependent name, along
with a list of system messages. If the role is not found in the current
language, check English. Return a 2-tuple: role function (``None`` if the
named role cannot be found) and a list of system messages.
Nz:Problem retrieving role entry from language module %r: %s.z&No role entry for "%s" in module "%s".z%Using English fallback for role "%s".z#Trying "%s" as canonical role name.�
��line)
�lower�_roles�roles�AttributeError�append�KeyError�__name__�DEFAULT_INTERPRETED_ROLE�_fallback_language_module�info�join�_role_registry�register_local_role)� role_name�language_module�lineno�reporter�normname�messages�msg_text�
canonicalname�error�message�role_fn� r$ �</usr/lib/python3/dist-packages/docutils/parsers/rst/roles.py�role^ sP ��
��
���
r&