ó V!¶\c@s©dZdZddlmZmZddlmZddlmZ ddl m Z m Z dZ iZiZd„Zd „Zd „Zd „Zd „Zd d2d„ƒYZdd3d„ƒYZigd„Ziejd6e_edejƒedejƒedejƒedejƒedejƒedejƒedej ƒedej!ƒigd„Z"ede"ƒigd„Z#ede#ƒigd„Z$iej%d6e$_ed e$ƒigd!„Z&iejd6ej%d"6e&_ed#e&ƒigd$„Z'ed%e'ƒid&„Z(ed'e(ƒed(e(ƒed)e(ƒed*e(ƒed+e(ƒed,e(ƒed-e(ƒed.e(ƒed/e(ƒd0„Z)d1S(4s 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). treStructuredTextiÿÿÿÿ(tnodestutils(t directives(ten(tLexert LexerErrorstitle-referencec Cst|jƒ}g}g}|tkr2t||fS|r©d}y|j|}Wq¯tk r{}|jd||fƒq¯tk r¥|jd||jfƒq¯Xnt}|sy"t j|}|jd|ƒWqtk r|jd|ƒ|}qXn|r9|j dj |ƒd|ƒ} |j| ƒn|t krft |} t || ƒ| |fSd|fSdS(s. 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. s:Problem retrieving role entry from language module %r: %s.s&No role entry for "%s" in module "%s".s%Using English fallback for role "%s".s#Trying "%s" as canonical role name.s tlineN(tlowert_rolestNonetrolestAttributeErrortappendtKeyErrort__name__tDEFAULT_INTERPRETED_ROLEt_fallback_language_moduletinfotjoint_role_registrytregister_local_role( t role_nametlanguage_moduletlinenotreportertnormnametmessagestmsg_textt canonicalnameterrortmessagetrole_fn((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytrole^sB               cCst|ƒ|t|/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytregister_canonical_role’s cCst|ƒ|t|/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyRs cCs[t|dƒ s|jdkr5itjd6|_n"d|jkrWtj|jd/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR"¨scCs t||ƒ}t||ƒdS(sAFor roles which simply wrap a given `node_class` around the text.N(t GenericRoleR$(tcanonical_namet node_classR!((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytregister_generic_role²sR)cBs&eZdZd„Zigd„ZRS(sw Generic interpreted text role, where the interpreted text is simply wrapped with the provided node class. cCs||_||_dS(N(R#R+(tselfRR+((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyt__init__¿s cCs/t|ƒ|j|tj|ƒ|ggfS(N(t set_classesR+Rtunescape(R-R!trawtextttextRtinlinerR%tcontent((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyt__call__Ãs (Rt __module__t__doc__R.R5(((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR)¸s t CustomRolecBs,eZdZigd„Zigd„ZRS(s4 Wrapper for custom interpreted text roles. cCsv||_||_d|_t|dƒr9|j|_nd|_t|dƒr`|j|_n||_||_dS(NR%R4(R#t base_roleR R%R'R4tsupplied_optionstsupplied_content(R-RR9R%R4((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR.Ïs     c Csv|jjƒ}|j|ƒt|jƒ} | rD|rD| d7} n| j|ƒ|j|||||d|d| ƒS(Ns R%R4(R:tcopytupdatetlistR;textendR9( R-R!R1R2RR3R%R4toptstcont((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR5Ûs    (RR6R7R.R5(((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR8És cCs/t|ƒtj|tj|ƒ|ggfS(t(R/RtinlineRR0(R!R1R2RR3R%R4((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytgeneric_custom_roleçs R&t abbreviationtacronymtemphasistliteraltstrongt subscriptt superscriptc CsÜy1t|ƒ}|dks'|dkr0t‚nWnOtk r‚|jjd|d|ƒ}|j|||ƒ} | g|gfSX|jjj|jjj|} t |ƒt j |dt j |ƒd| |ggfS(Nii's<PEP number must be a number from 0 to 9999; "%s" is invalid.RsPEP trefuri(tintt ValueErrorRRt problematictdocumenttsettingst pep_base_urltpep_file_url_templateR/Rt referenceRR0( R!R1R2RR3R%R4tpepnumtmsgtprbtref((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytpep_reference_roleÿs      s pep-referencec CsÐy%t|ƒ}|dkr$t‚nWnOtk rv|jjd|d|ƒ}|j|||ƒ} | g|gfSX|jjj|j|} t |ƒt j |dt j |ƒd| |} | ggfS(NisHRFC number must be a number greater than or equal to 1; "%s" is invalid.RsRFC RL(RMRNRRRORPRQt rfc_base_urltrfc_urlR/RRTRR0( R!R1R2RR3R%R4trfcnumRVRWRXtnode((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytrfc_reference_roles       s rfc-referencec Csé|jjjsF|jjdƒ}|j|||ƒ}|g|gfSd|kr“|jjd|d|ƒ}|j|||ƒ}|g|gfSt|ƒtj |t j |dƒ|} |jj |ƒ\| _ | _| ggfS(Ns raw (and derived) roles disabledtformatsµNo format (Writer name) is associated with this role: "%s". The "raw" role cannot be used directly. Instead, use the "role" directive to create a new role with an associated format.Ri(RPRQt raw_enabledRtwarningRORR/RtrawRR0tget_source_and_linetsourceR( R!R1R2RR3R%R4RVRWR]((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytraw_role)s   !R_RbcCsSt|ƒ|jddƒ}dg}d|krE|j|dƒn|rg||krg|j|ƒny+ttj|dƒ||jjj ƒ} WnGt k rÛ} |j j | ƒ} |j ||| ƒ} | g| gfSXtj|dd|ƒ} xO| D]G\}}|r,| tj||d|ƒ7} qû| tj||ƒ7} qûW| ggfS(NtlanguageRBtcodetclassesi(R/tgetR?R RRR0RPRQtsyntax_highlightRRRaRORRHRCtText(R!R1R2RR3R%R4RfRhttokensRRVRWR]tvalue((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyt code_role?s(   RfRgc CsNt|ƒ|jdƒ}|jdƒd}tj|||}|ggfS(Nt`i(R/tfindtsplitRtmath( R!R1R2RR3R%R4tiR]((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyt math_roleas  RrcCsA|jjd|d|ƒ}|j|||ƒ}|g|gfS(Ns+Interpreted text role "%s" not implemented.R(RRRO(R!R1R2RR3t attributesRVRW((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytunimplemented_rolens tindexsnamed-referencesanonymous-references uri-referencesfootnote-referencescitation-referencessubstitution-referencettargets#restructuredtext-unimplemented-rolecCs:d|kr6d|kst‚|d|d<|d=ndS(sW Auxiliary function to set options['classes'] and delete options['class']. R&RhN(tAssertionError(R%((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pyR/‚s N(((*R7t __docformat__tdocutilsRRtdocutils.parsers.rstRtdocutils.parsers.rst.languagesRRtdocutils.utils.code_analyzerRRRRR R!R$RR"R,R)R8RDR(R%RERFRGRHRIRJRKttitle_referenceRYR^Ret unchangedRnRtRvR/(((s>/tmp/pip-install-usGedi/docutils/docutils/parsers/rst/roles.pytGsd 4