m iEc@sN dZdZdkZdkZdkZdkZdklZlZl Z l Z l Z l Z l Z dklZdfdYZdeefdYZd efd YZd efd YZd efdYZdfdYZdfdYZdfdYZdfdYZdfdYZdfdYZdefdYZdfdYZdfd YZd!efd"YZd#efd$YZd%efd&YZd'efd(YZ d)efd*YZ!d+fd,YZ"d-fd.YZ#d/efd0YZ$d1efd2YZ%d3fd4YZ&d5eeefd6YZ'd7eeefd8YZ(d9eeefd:YZ)d;eefd<YZ*d=eefd>YZ+d?eefd@YZ,dAeefdBYZ-dCeefdDYZ.dEeefdFYZ/dGeefdHYZ0dIeefdJYZ1dKeefdLYZ2dMeefdNYZ3dOeefdPYZ4dQeefdRYZ5dSeefdTYZ6dUeefdVYZ7dWeefdXYZ8dYeefdZYZ9d[eefd\YZ:d]eefd^YZ;d_eefd`YZ<daeefdbYZ=dceefddYZ>deeefdfYZ?dgeefdhYZ@dieefdjYZAdke"efdlYZBdmeefdnYZCdoe"efdpYZDdqe"efdrYZEdse"efdtYZFdue"efdvYZGdweefdxYZHdye"efdzYZId{e"efd|YZJd}e"efd~YZKde"efdYZLde"efdYZMde"efdYZNdeefdYZOde"efdYZPde"efdYZQde"efdYZRdeefdYZSdeefdYZTdeefdYZUde"efdYZVdeefdYZWde"efdYZXdeefdYZYdeefdYZZdeefdYZ[deefdYZ\deefdYZ]deefdYZ^deefdYZ_deefdYZ`deefdYZadeefdYZbde e!efdYZcde e!efdYZdde e!e#ee%fdYZedeeee&e%fdYZfdeeee&e%fdYZgde"efdYZhdeefdYZide"efdYZjde"efdYZkdeefdYZlde"efdYZmde"efdYZnde"efdYZode"efdYZpde"efdYZqde"efdYZrde eeefdYZsde e!efdYZtde e#eefdYZude#efdYZvde#efdYZwde#efdYZxdee#e$efdYZyde#e$efdYZzde#e$efdYZ{de#efdYZ|de#efdYZ}de#efdYZ~de#efdYZde#efdYZde#efdYZdee#efdYZde#efdYZde#efdYZde#efdYZdiZdfdYZdefdYZdefdYZdZdZdZdZeedefdYZdefdYZdefdYZdefdYZdefdYZdefd YZd efd YZd Zeid ZeidZdZdZdZdZdS(s Docutils document tree element class library. Classes in CamelCase are abstract base classes or auxiliary classes. The one exception is `Text`, for a text (PCDATA) node; uppercase is used to differentiate from element classes. Classes in lower_case_with_underscores are element classes, matching the XML element generic identifiers in the DTD_. The position of each node (the level at which it can occur) is significant and is represented by abstract base classes (`Root`, `Structural`, `Body`, `Inline`, etc.). Certain transformations will be easier because we can use ``isinstance(node, base_class)`` to determine the position of the node in the hierarchy. .. _DTD: http://docutils.sourceforge.net/docs/ref/docutils.dtd treStructuredTextN(sIntTypes SliceTypes StringTypes UnicodeTypes TupleTypesListTypes ClassType(s UserStringtNodecBstZdZeZeZeZeZdZedZ dddZ dZ dZ dZ d Zd Zed d ddd Zedd ddd ZRS(s0Abstract base class of nodes in a document tree.cCsdS(s8 Node instances are always true, even if they're empty. A node is more than a simple container. Its boolean "truth" does not depend on having one or more subnodes in the doctree. Use `len()` to check node length. Use `None` to represent a boolean false value. iN((tself((t-/data/zmath/zope/lib/python/docutils/nodes.pyt __nonzero__7scCs9|djodkii}n|i}|i|S(s6Return a DOM **fragment** representation of this Node.N(tdomtNonetxml.dom.minidomtminidomtDocumenttdomrootRt _dom_node(RRR ((RtasdomBs   s icCs tdS(ss Return an indented pseudo-XML representation, for test purposes. Override in subclasses. N(tNotImplementedError(Rtindenttlevel((RtpformatIscCs tdS(sReturn a copy of self.N(R (R((RtcopyQscCs tdS(s3Return a deep copy of self (also copying children).N(R (R((RtdeepcopyUscCsm||_|ioV|i|_|idjo|ii|_n|idjo|ii|_qindS(N( RtchildtparenttdocumenttsourceRtcurrent_sourcetlinet current_line(RR((Rt setup_childYs   cCs|iiid|iiy|i|Wn/tt fj o dSnt j onX|i }y#x|D]}|i |qtWWntj onXdS(s Traverse a tree of `Node` objects, calling the `dispatch_visit()` method of `visitor` when entering each node. (The `walkabout()` method is similar, except it also calls the `dispatch_departure()` method before exiting each node.) This tree traversal supports limited in-place tree modifications. Replacing one node with one or more nodes is OK, as is removing an element. However, if the node removed or replaced occurs after the current node, the old node will still be traversed, and any new nodes will not. Within ``visit`` methods (and ``depart`` methods for `walkabout()`), `TreePruningException` subclasses may be raised (`SkipChildren`, `SkipSiblings`, `SkipNode`, `SkipDeparture`). Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` implementation for each `Node` subclass encountered. s6docutils.nodes.Node.walk calling dispatch_visit for %sN(tvisitorRtreportertdebugRt __class__t__name__tdispatch_visitt SkipChildrentSkipNodet SkipDeparturetchildrenRtwalkt SkipSiblings(RRRR$((RR%bs cCsd}|iiid|iiyy|i|Wn/t j o dSnt j o d}nX|i }y#x|D]}|i |q}WWntj onXWntj onX|o.|iiid|ii|i|ndS(sP Perform a tree traversal similarly to `Node.walk()` (which see), except also call the `dispatch_departure()` method before exiting each node. Parameter `visitor`: A `NodeVisitor` object, containing a ``visit`` and ``depart`` implementation for each `Node` subclass encountered. is;docutils.nodes.Node.walkabout calling dispatch_visit for %sNis?docutils.nodes.Node.walkabout calling dispatch_departure for %s(t call_departRRRRRRRR R"R#R$Rt walkaboutR&R!tdispatch_departure(RRR'RR$((RR(s,    ic Csng} |o d}nt|to|}|d}n|o+|d jp ||o| i |n|oVt |i oFxC|D]7} | i| iddddddddd|qWn|p|o|}x|iox|ii|}xJ|i|dD]7} | i| iddd|ddddd|qW|pPq|i}qWn| S( s Return an iterable containing * self (if include_self is true) * all descendants in tree traversal order (if descend is true) * all siblings (if siblings is true) and their descendants (if also descend is true) * the siblings of the parent (if ascend is true) and their descendants (if also descend is true), and so on If `condition` is not None, the iterable contains only nodes for which ``condition(node)`` is true. If `condition` is a node class ``cls``, it is equivalent to a function consisting of ``return isinstance(node, cls)``. If ascend is true, assume siblings to be true as well. For example, given the following tree:: <--- emphasis.traverse() and <--- strong.traverse() are called. Foo Bar Baz Then list(emphasis.traverse()) equals :: [, , <#text: Foo>, <#text: Bar>] and list(strong.traverse(ascend=1)) equals :: [, <#text: Foo>, <#text: Bar>, , <#text: Baz>] icCs t||S(N(t isinstancetnodet node_class(R+R,((Rt conditionst include_selftdescendtsiblingsitascendR-N(trR1R0R*R-t ClassTypeR,R.RRtappendR/tlenR$RtextendttraverseR+Rtindextsibling( RR-R.R/R0R1R+R8R,R9R2R((RR7s8$ !$  c CsT|id|d|d|d|d|}y |dSWntj o dSnXdS(s Return the first node in the iterable returned by traverse(), or None if the iterable is empty. Parameter list is the same as of traverse. Note that include_self defaults to 0, though. R-R.R/R0R1iN( RR7R-R.R/R0R1titerablet IndexErrorR(RR-R.R/R0R1R:((Rt next_nodes   (Rt __module__t__doc__RRRRRRR RRRRR%R(R7R<(((RR's&     % #AtTextcBsttZdZdZfZddZdZdZdZdZ dZ d Z d Z d d d Z RS(s Instances are terminal nodes (leaves) containing text only; no child nodes or attributes. Initialize by passing a string to the constructor. Access the text itself with the `astext` method. s#texttcCsti||||_dS(N(t UserStringt__init__Rtdatat rawsource(RRCRD((RRB scCsNt|i}t|djot|id d}nd|i|fS(NiFi@s ...s<%s: %s>(treprRRCR5ttagname(RRC((Rt__repr__scCs t|iS(N(R5RRC(R((Rt__len__scCsNt|i}t|djot|id d}nd|i|fS(Niis ...s<%s: %s>(RERRCR5RF(RRC((Rt shortreprscCs|i|iS(N(R tcreateTextNodeRRC(RR ((RR scCs|iS(N(RRC(R((Rtastext!scCs|i|iS(N(RRRC(R((RR$scCs |iS(N(RR(R((RR'ss icCsLg}||}x,|iiD]}|i||dq Wdi|S(Ns R@( tresultRRRRCt splitlinesRR4tjoin(RRRRRL((RR*s  (RR=R>RFR$RBRGRHRIR RKRRR(((RR?s         tElementcBstZdZd4ZeZdZddZd Zd Z d Z d Z d Z dZ dZdZdZdZdZdZdZdZdZdZdZdZedZdZdZedZeZdZd Z d!Z!d"d#Z"d$Z#d%Z$d&Z%d'Z&d(Z'd)Z(d*Z)d+e*i+d,Z,d+e*i+d-Z-d.d+d/Z.d0Z/d1Z0d2Z1eed3Z2RS(5s `Element` is the superclass to all specific elements. Elements contain attributes and child nodes. Elements emulate dictionaries for attributes, indexing by attribute name (a string). To set the attribute 'att' to 'value', do:: element['att'] = 'value' There are two special attributes: 'ids' and 'names'. Both are lists of unique identifiers, and names serve as human interfaces to IDs. Names are case- and whitespace-normalized (see the fully_normalize_name() function), and IDs conform to the regular expression ``[a-z](-?[a-z0-9]+)*`` (see the make_id() function). Elements also emulate lists for child nodes (element nodes and/or text nodes), indexing by integer. To get the first child node, use:: element[0] Elements may be constructed using the ``+=`` operator. To add one new child node to element, do:: element += node This is equivalent to ``element.append(node)``. To add a list of multiple child nodes at once, use the same ``+=`` operator:: element += [node1, node2] This is equivalent to ``element.extend([node1, node2])``. tidstclassestnamestdupnamestbackrefss R@cOs||_g|_|i|h|_x|iD]}g|i|s; s<%s: %s>( RCRR$tcRIR5RRRN(RRCRf((RRGs   (cCs?|do%d|iidi|dfSn d|iSdS(NRRs <%s "%s"...>s; s<%s...>(RRRRNRF(R((RRIs %cCs|iidS(Ntraw_unicode_escape(Rt __unicode__tencode(R((Rt__str__scCsf|ioNd|idig}|iD]}|t|q*~|ifSn |iSdS(Nu%s%s%sR@( RR$tstarttagRNRaRftstrtendtagtemptytag(RRaRf((RRhs NcCs|ig}x|iD]\}}|djo|i|qt|t oOg}|D]}|t d|q^~}|id|di|fq|id||fqWddi|S(Ns%ss%s="%s"R[s<%s>(RRFtpartsR^tnameRYRR4R*R`RaRbRctvaluesRN(RRpRYRaRoRqRb((RRks   +$cCs d|iS(Ns(RRF(R((RRmsc CsLddi|igg}|iD]\}}|d||fq#~S(Nu<%s/>R[s%s="%s"(RNRRFRaR^tnRb(RRaRbRr((RRnscCs t|iS(N(R5RR$(R((RRHscCst|tpt|to|i|Snkt|to|i|SnLt|to2|i djp t d|i|i |i !Sn tddS(Niscannot handle slice with stridesFelement index must be an integer, a slice, or an attribute name string(Ni(R*tkeyt UnicodeTypet StringTypeRRUtIntTypeR$t SliceTypetstepRtAssertionErrortstarttstopt TypeError(RRs((Rt __getitem__s cCst|tpt|to||it|s  cCs|}t|tp.y|d}WqDtj o d}qDXnt|to|i|n6x2dD]*}|| pt d|||fqlW|i i ||dS( sc Replace `self` node with `new`, where `new` is a node or a list of nodes. iRPRRRQRSsLosing "%s" attribute: %sN(sidssnamessclassessdupnames( RtupdateR*RR;RRORRRWRyRR(RRRRW((Rt replace_selfGs(icCswt|tp |f}nxSt|tt||D]3}x*|D]"}t|||o|SqIqIWq<WdS(sM Return the index of the first child whose class exactly matches. Parameters: - `childclass`: A `Node` subclass to search for, or a tuple of `Node` classes. If a tuple, any of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* check. N( R*t childclasst TupleTypetrangeRztminR5RtendR8RfR(RRRzRR8Rf((Rtfirst_child_matching_class]s  cCs{t|tp |f}nxWt|tt||D]7}x.|D]"}t|i ||oPqIqIW|Sq<WdS(sI Return the index of the first child whose class does *not* match. Parameters: - `childclass`: A `Node` subclass to skip, or a tuple of `Node` classes. If a tuple, none of the classes may match. - `start`: Initial index to check. - `end`: Initial index to *not* check. N( R*RRRRzRR5RRR8RfR$R(RRRzRR8Rf((Rtfirst_child_not_matching_classps   s c CsVdid|||ifgg}|iD]}||i||dq.~S(NR@s%s%s i( RNRRRRkRaR$RR(RRRRaR((RRscCs|i|iS(N(RRRU(R((RRscCsA|i}|ig}|iD]}||iq ~|S(N(RRR6RaR$RR(RRaRR((RRs 1cCsEtidtddd|jpt|di|idS(s+Add a new class to the "classes" attribute.sadocutils.nodes.Element.set_class deprecated; append to Element['classes'] list attribute directlyt stackleveliR[RQN(twarningstwarntDeprecationWarningRpRyRR4RZ(RRp((Rt set_classs   cCsd|_t|dhi|}t|dhi|}|o!|dj pt d|_n|o!|dj pt d|_ndS(sQNote that this Element has been referenced by its name `name` or id `id`.itexpect_referenced_by_nametexpect_referenced_by_idN( Rt referencedtgetattrRRptby_nametidtby_idRRy(RRpRRR((Rtnote_referenced_bys  (sidssclassessnamessdupnamesRT(3RR=R>RVRRFRRBR RGRIRjRhRkRmRnRHR}RRRRRRKRR^RRRRRR4R6RRRR8RRRRRtsystmaxintRRRRRRR(((RRO2sb #                              t TextElementcBs#tZdZdZdddZRS(s An element which directly contains text. Its children are all `Text` or `Inline` subclass nodes. You can check whether an element's context is inline simply by checking whether its immediate parent is a `TextElement` instance (including subclasses). This is handy for nodes like `image` that can appear both inline and as standalone body elements. If passing children to `__init__()`, make sure to set `text` to ``''`` or some other suitable value. R@cOsP|djo)t|}ti|||||nti||||dS(NR@( ttextR?ttextnodeRORBRRDR$RU(RRDRR$RUR((RRBs  (RR=R>RRB(((RRs tFixedTextElementcBstZdZdddZRS(s5An element which directly contains preformatted text.R@cOs*ti|||||d|idRB(((RRs t ResolvablecBstZdZRS(Ni(RR=tresolved(((RRst BackLinkablecBstZdZRS(NcCs|di|dS(NRT(RR4trefid(RR((Rt add_backrefs(RR=R(((RRstRootcBstZRS(N(RR=(((RRstTitularcBstZRS(N(RR=(((RRstPreBibliographiccBstZdZRS(s<Category of Node which may occur before Bibliographic Nodes.(RR=R>(((RRs t BibliographiccBstZRS(N(RR=(((RRst DecorativecBstZRS(N(RR=(((RRst StructuralcBstZRS(N(RR=(((RRstBodycBstZRS(N(RR=(((RRstGeneralcBstZRS(N(RR=(((RRst SequentialcBstZdZRS(sList-like elements.(RR=R>(((RRs t AdmonitioncBstZRS(N(RR=(((RRstSpecialcBstZdZRS(sSpecial internal body elements.(RR=R>(((RRs t InvisiblecBstZdZRS(s.Internal elements that don't appear in output.(RR=R>(((RRs tPartcBstZRS(N(RR=(((RRstInlinecBstZRS(N(RR=(((RRst ReferentialcBstZRS(N(RR=(((RRst TargetablecBstZdZdZRS(Ni(RR=RRtindirect_reference_name(((RRstLabeledcBstZdZRS(s(Contains a `label` as its first element.(RR=R>(((RRs RcBs"tZdZdZedZedZeedZdZdZ edZ edZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZedZdZedZdZdZdZdZdZRS(s The document root element. Do not instantiate this class directly; use `docutils.utils.new_document()` instead. cOs(ti|||d|_d|_||_||_ g|_ h|_ h|_ h|_ h|_h|_h|_h|_h|_h|_g|_g|_g|_g|_g|_g|_d|_d|_d|_g|_g|_dk}|i!i"||_#d|_$||_%dS(Nii(&RORBRtargstkwargsRRRtsettingsRtindirect_targetstsubstitution_defstsubstitution_namestrefnamestrefidstnameidst nametypesRPt footnote_refst citation_refst autofootnotestautofootnote_refstsymbol_footnotestsymbol_footnote_refst footnotest citationstautofootnote_starttsymbol_footnote_starttid_starttparse_messagesttransform_messagestdocutils.transformstdocutilst transformst Transformert transformert decorationR(RRRRRR((RRB!sr                           cCsF|djodkii}n|i}|i|i||S(s-Return a DOM representation of this document.N( RRRRR R ReRR (RRR ((RR zs   cCsHxn|dD]b}|ii|oI|i||j o5|iid|}|djo||7}qmq q W|dpx|dD]<}|i i t |}|o|ii| oPqqWd}xR| p|ii|o6|i i |i it|i}|id7_qW|di|n||i|<|S(NRPsDuplicate ID: "%s".RRR@i(R+RRRPRRtseveretmsgtmsgnodeRRpRt id_prefixtmake_idtauto_id_prefixRlRR4(RR+RRpRR((Rtset_ids( '    # cCscx\|dD]P}|ii|o|i|||||q ||i|<||i ||i||ii|dgi||i|dS(NR(RRR RRR4R(RR ((Rtnote_footnote_refs  cCs|ii|dS(N(RRR4tcitation(RR((Rt note_citationscCs>|i||ii|dgi||i|dS(NR(RRR RRR4R(RR ((Rtnote_citation_refs  cCst|}|ii|oU|iid|d|}|djo||7}n|i|}t ||n||i|<||it|s   cCs|i|i|i|iS(N(RRRRRU(R((RREscCsd|ipSt|_|it}|djo|i|iq]|i||in|iS(N(RRRRR8RR4R(RR8((Rtget_decorationIs   ( RR=R>RBRR RRRRRRRRRRRR R R R RRRRRRR R!R#RR$(((RRs:  Y  ' *                      ttitlecBstZRS(N(RR=(((RR%XstsubtitlecBstZRS(N(RR=(((RR&YstrubriccBstZRS(N(RR=(((RR'ZstdocinfocBstZRS(N(RR=(((RR(astauthorcBstZRS(N(RR=(((RR)bstauthorscBstZRS(N(RR=(((RR*cst organizationcBstZRS(N(RR=(((RR+dstaddresscBstZRS(N(RR=(((RR,estcontactcBstZRS(N(RR=(((RR-fstversioncBstZRS(N(RR=(((RR.gstrevisioncBstZRS(N(RR=(((RR/hststatuscBstZRS(N(RR=(((RR0istdatecBstZRS(N(RR=(((RR1jst copyrightcBstZRS(N(RR=(((RR2ksRcBstZdZdZRS(NcCsKt|i pt|idt o|idtn|idS(Ni(R5RR$R*theaderR(R((Rt get_headerts)cCsHt|i pt|idt o|itn|idS(Ni(R5RR$R*tfooterR4(R((Rt get_footerys)(RR=R4R6(((RRrs R3cBstZRS(N(RR=(((RR3sR5cBstZRS(N(RR=(((RR5stsectioncBstZRS(N(RR=(((RR7sttopiccBstZdZRS(s Topics are terminal, "leaf" mini-sections, like block quotes with titles, or textual figures. A topic is just like a section, except that it has no subsections, and it doesn't have to conform to section placement rules. Topics are allowed wherever body elements (list, table, etc.) are allowed, but only at the top level of a section or document. Topics cannot nest inside topics, sidebars, or body elements; you can't have a topic inside a table, list, block quote, etc. (RR=R>(((RR8s tsidebarcBstZdZRS(s Sidebars are like miniature, parallel documents that occur inside other documents, providing related or reference material. A sidebar is typically offset by a border and "floats" to the side of the page; the document's main text may flow around it. Sidebars can also be likened to super-footnotes; their content is outside of the flow of the document's main text. Sidebars are allowed wherever body elements (list, table, etc.) are allowed, but only at the top level of a section or document. Sidebars cannot nest inside sidebars, topics, or body elements; you can't have a sidebar inside a table, list, block quote, etc. (RR=R>(((RR9s t transitioncBstZRS(N(RR=(((RR:st paragraphcBstZRS(N(RR=(((RR;stcompoundcBstZRS(N(RR=(((RR<st containercBstZRS(N(RR=(((RR=st bullet_listcBstZRS(N(RR=(((RR>stenumerated_listcBstZRS(N(RR=(((RR?st list_itemcBstZRS(N(RR=(((RR@stdefinition_listcBstZRS(N(RR=(((RRAstdefinition_list_itemcBstZRS(N(RR=(((RRBsttermcBstZRS(N(RR=(((RRCst classifiercBstZRS(N(RR=(((RRDst definitioncBstZRS(N(RR=(((RREst field_listcBstZRS(N(RR=(((RRFstfieldcBstZRS(N(RR=(((RRGst field_namecBstZRS(N(RR=(((RRHst field_bodycBstZRS(N(RR=(((RRIstoptioncBstZdZRS(NR@(RR=R(((RRJstoption_argumentcBstZdZRS(NcCs|iddti|S(Nt delimiterR[(RRRRK(R((RRKs(RR=RK(((RRKst option_groupcBstZdZRS(Ns, (RR=R(((RRMst option_listcBstZRS(N(RR=(((RRNstoption_list_itemcBstZdZRS(Ns (RR=R(((RROst option_stringcBstZRS(N(RR=(((RRPst descriptioncBstZRS(N(RR=(((RRQst literal_blockcBstZRS(N(RR=(((RRRst doctest_blockcBstZRS(N(RR=(((RRSst line_blockcBstZRS(N(RR=(((RRTsRcBstZdZRS(N(RR=RR(((RRst block_quotecBstZRS(N(RR=(((RRUst attributioncBstZRS(N(RR=(((RRVst attentioncBstZRS(N(RR=(((RRWstcautioncBstZRS(N(RR=(((RRXstdangercBstZRS(N(RR=(((RRYsRcBstZRS(N(RR=(((RRst importantcBstZRS(N(RR=(((RRZstnotecBstZRS(N(RR=(((RR[sttipcBstZRS(N(RR=(((RR\sthintcBstZRS(N(RR=(((RR]stwarningcBstZRS(N(RR=(((RR^st admonitioncBstZRS(N(RR=(((RR_stcommentcBstZRS(N(RR=(((RR`stsubstitution_definitioncBstZRS(N(RR=(((RRasRcBstZRS(N(RR=(((RRsRcBstZRS(N(RR=(((RRsRcBstZRS(N(RR=(((RRstlabelcBstZRS(N(RR=(((RRbstfigurecBstZRS(N(RR=(((RRcstcaptioncBstZRS(N(RR=(((RRdstlegendcBstZRS(N(RR=(((RResttablecBstZRS(N(RR=(((RRfsttgroupcBstZRS(N(RR=(((RRgstcolspeccBstZRS(N(RR=(((RRhsttheadcBstZRS(N(RR=(((RRisttbodycBstZRS(N(RR=(((RRjstrowcBstZRS(N(RR=(((RRkstentrycBstZRS(N(RR=(((RRlsRcBs#tZdZedZdZRS(s System message element. Do not instantiate this class directly; use ``document.reporter.info/warning/error/severe()`` instead. cOs^|o td|}|f|}nyti|d||Wnd|fGHnXdS(NR@ssystem_message: children=%r(RR;tpR$RORBRRU(RRR$RURm((RRB s cCs>|idd}d|d||d|dti|fS(NRR@u%s:%s: (%s/%s) %sRttypeR(RRRRORK(RR((RRKs(RR=R>RRBRK(((RRs  RcBs5tZdZeddZdddZdZRS(sF The "pending" element is used to encapsulate a pending operation: the operation (transform), the point at which to apply it, and any data it requires. Only the pending operation's location within the document is stored in the public document tree (by the "pending" object itself); the operation and its data are stored in the "pending" object's internal instance attributes. For example, say you want a table of contents in your reStructuredText document. The easiest way to specify where to put it is from within the document, with a directive:: .. contents:: But the "contents" directive can't do its work until the entire document has been parsed and possibly transformed to some extent. So the directive code leaves a placeholder behind that will trigger the second phase of its processing, something like this:: + internal attributes Use `document.note_pending()` so that the `docutils.transforms.Transformer` stage of processing can run all pending transforms. R@cOs3ti||||||_|ph|_dS(N(RORBRRDR$RUt transformtdetails(RRoRpRDR$RU((RRB8s s ic Csdd|ii|iifdg}|ii}|ix,|D]$\}}t |t oY|i dd|f|i g}|iiD]} |dd| fq~qE|ot |to~t |dt oj|i dd|fxj|D]D}|i g}|iiD]} |dd| fq&~qWqE|i dd||fqEWti|||dig}|D]} |d ||| fq~S( Ns.. internal attributes:s .transform: %s.%ss .details:s%7s%s:R@s%9s%sis %7s%s: %rs %s%s (RRoR=Rt internalsRpRXRRsRYR*RR4R6RaRRMRR`RbRORRRN( RRRRqRYRaRpRsRbR((RRCs%  B+FcCs"|i|i|i|i|iS(N(RRRoRpRDRU(R((RR\s(RR=R>RRBRR(((RRs  trawcBstZdZRS(s@ Raw data that is to be passed untouched to the Writer. (RR=R>(((RRras temphasiscBstZRS(N(RR=(((RRsnststrongcBstZRS(N(RR=(((RRtostliteralcBstZRS(N(RR=(((RRupst referencecBstZRS(N(RR=(((RRvqstfootnote_referencecBstZRS(N(RR=(((RRwrstcitation_referencecBstZRS(N(RR=(((RRxsstsubstitution_referencecBstZRS(N(RR=(((RRytsttitle_referencecBstZRS(N(RR=(((RRzust abbreviationcBstZRS(N(RR=(((RR{vstacronymcBstZRS(N(RR=(((RR|wst superscriptcBstZRS(N(RR=(((RR}xst subscriptcBstZRS(N(RR=(((RR~ystimagecBstZdZRS(NcCs|iddS(NtaltR@(RR(R((RRK~s(RR=RK(((RR|stinlinecBstZRS(N(RR=(((RRst problematiccBstZRS(N(RR=(((RRst generatedcBstZRS(N(RR=(((RRss( Text abbreviation acronym address admonition attention attribution author authors block_quote bullet_list caption caution citation citation_reference classifier colspec comment compound contact container copyright danger date decoration definition definition_list definition_list_item description docinfo doctest_block document emphasis entry enumerated_list error field field_body field_list field_name figure footer footnote footnote_reference generated header hint image important inline label legend line line_block list_item literal literal_block note option option_argument option_group option_list option_list_item option_string organization paragraph pending problematic raw reference revision row rubric section sidebar status strong subscript substitution_definition substitution_reference subtitle superscript system_message table target tbody term tgroup thead tip title title_reference topic transition version warningt NodeVisitorcBsAtZdZfZdZdZdZdZdZRS(s "Visitor" pattern [GoF95]_ abstract superclass implementation for document tree traversals. Each node class has corresponding methods, doing nothing by default; override individual methods for specific and useful behaviour. The `dispatch_visit()` method is called by `Node.walk()` upon entering a node. `Node.walkabout()` also calls the `dispatch_departure()` method before exiting a node. The dispatch methods call "``visit_`` + node class name" or "``depart_`` + node class name", resp. This is a base class for visitors whose ``visit_...`` & ``depart_...`` methods should be implemented for *all* node types encountered (such as for `docutils.writers.Writer` subclasses). Unimplemented methods will raise exceptions. For sparse traversals, where only certain node types are of interest, subclass `SparseNodeVisitor` instead. When (mostly or entirely) uniform processing is desired, subclass `GenericNodeVisitor`. .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA, 1995. cCs ||_dS(N(RR(RR((RRBscCsO|ii}t|d||i}|ii i d|i|f||S(s Call self."``visit_`` + node class name" with `node` as parameter. If the ``visit_...`` method does not exist, call self.unknown_visit. tvisit_s;docutils.nodes.NodeVisitor.dispatch_visit calling %s for %sN( R+RRt node_nameRRt unknown_visittmethodRRR(RR+RR((RR s   cCsO|ii}t|d||i}|ii i d|i|f||S(s Call self."``depart_`` + node class name" with `node` as parameter. If the ``depart_...`` method does not exist, call self.unknown_departure. tdepart_s?docutils.nodes.NodeVisitor.dispatch_departure calling %s for %sN( R+RRRRRtunknown_departureRRRR(RR+RR((RR)s   cCsM|iiip|ii|ijo#td|i|iifndS(sk Called when entering unknown `Node` types. Raise an exception unless overridden. s!%s visiting unknown node type: %sN( R+RRtstrict_visitorRRRtoptionalR (RR+((RRs&cCsM|iiip|ii|ijo#td|i|iifndS(si Called before exiting unknown `Node` types. Raise exception unless overridden. s"%s departing unknown node type: %sN( R+RRRRRRRR (RR+((RRs&( RR=R>RRBR R)RR(((RRs   tSparseNodeVisitorcBstZdZRS(s Base class for sparse traversals, where only certain node types are of interest. When ``visit_...`` & ``depart_...`` methods should be implemented for *all* node types (such as for `docutils.writers.Writer` subclasses), subclass `NodeVisitor` instead. (RR=R>(((RRs tGenericNodeVisitorcBs tZdZdZdZRS(s Generic "Visitor" abstract superclass, for simple traversals. Unless overridden, each ``visit_...`` method calls `default_visit()`, and each ``depart_...`` method (when using `Node.walkabout()`) calls `default_departure()`. `default_visit()` (and `default_departure()`) must be overridden in subclasses. Define fully generic visitors by overriding `default_visit()` (and `default_departure()`) only. Define semi-generic visitors by overriding individual ``visit_...()`` (and ``depart_...()``) methods also. `NodeVisitor.unknown_visit()` (`NodeVisitor.unknown_departure()`) should be overridden for default behavior. cCs tdS(s)Override for generic, uniform traversals.N(R (RR+((Rt default_visit"scCs tdS(s)Override for generic, uniform traversals.N(R (RR+((Rtdefault_departure&s(RR=R>RR(((RRs  cCs|i|dS(N(RRR+(RR+((Rt_call_default_visit*scCs|i|dS(N(RRR+(RR+((Rt_call_default_departure-scCsdS(N((RR+((Rt_nop0scCsex^|D]V}ttd|tttd|tttd|tttd|tqWdS(s%Save typing with dynamic assignments:RRN(RRt_nametsetattrRRRRR(RRR((Rt_add_node_class_names3stTreeCopyVisitorcBs2tZdZdZdZdZdZRS(sQ Make a complete copy of a tree or branch, including element attributes. cCs&ti||g|_g|_dS(N(RRBRRt parent_stackR(RR((RRBDs cCs |idS(Ni(RR(R((Rt get_tree_copyIscCs<|i}|ii||ii|i||_dS(s9Copy the current node, and make it the new acting parent.N(R+RtnewnodeRRR4R(RR+R((RRLs  cCs|ii|_dS(s#Restore the previous acting parent.N(RRRR(RR+((RRSs(RR=R>RBRRR(((RR>s    tTreePruningExceptioncBstZdZRS(s Base class for `NodeVisitor`-related tree pruning exceptions. Raise subclasses from within ``visit_...`` or ``depart_...`` methods called from `Node.walk()` and `Node.walkabout()` tree traversals to prune the tree traversed. (RR=R>(((RRXs R!cBstZdZRS(s Do not visit any children of the current node. The current node's siblings and ``depart_...`` method are not affected. (RR=R>(((RR!es R&cBstZdZRS(s Do not visit any more siblings (to the right) of the current node. The current node's children and its ``depart_...`` method are not affected. (RR=R>(((RR&os R"cBstZdZRS(sq Do not visit the current node's children, and do not call the current node's ``depart_...`` method. (RR=R>(((RR"ys R#cBstZdZRS(s Do not call the current node's ``depart_...`` method. The current node's children and siblings are not affected. (RR=R>(((RR#s t NodeFoundcBstZdZRS(s Raise to indicate that the target of a search has been found. This exception must be caught by the client; it is not caught by the traversal code. (RR=R>(((RRs cCsCtiddi|ii}tid|}t|S(s Convert `string` into an identifier and return it. Docutils identifiers will conform to the regular expression ``[a-z](-?[a-z0-9]+)*``. For CSS compatibility, identifiers (the "class" and "id" attributes) should have no underscores, colons, or periods. Hyphens may be used. - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). - However the `CSS1 spec`_ defines identifiers based on the "name" token, a tighter interpretation ("flex" tokenizer notation; "latin1" and "escape" 8-bit characters have been replaced with entities):: unicode \[0-9a-f]{1,4} latin1 [¡-ÿ] escape {unicode}|\[ -~¡-ÿ] nmchar [-a-z0-9]|{latin1}|{escape} name {nmchar}+ The CSS1 "nmchar" rule does not include underscores ("_"), colons (":"), or periods ("."), therefore "class" and "id" attributes should not contain these characters. They should be replaced with hyphens ("-"). Combined with HTML's requirements (the first character must be a letter; no "unicode", "latin1", or "escape" characters), this results in the ``[a-z](-?[a-z0-9]+)*`` pattern. .. _HTML 4.01 spec: http://www.w3.org/TR/html401 .. _CSS1 spec: http://www.w3.org/TR/REC-CSS1 t-R[R@N( t _non_id_charstsubRNtstringRZtsplitRt_non_id_at_endsRl(RR((RRs"'s [^a-z0-9]+s ^[-0-9]+|-+$cCs/|di||di|d|_dS(NRSRRi(R+R4RpRR(R+Rp((RRscCsdi|iiS(s.Return a case- and whitespace-normalized name.R[N(RNRpRZR(Rp((RRscCsdi|iS(s$Return a whitespace-normalized name.R[N(RNRpR(Rp((RRscCs|iddiddS(sDEscape string values that are elements of a list, for serialization.s\s\\R[s\ N(RYR(RY((RRcs(R>t __docformat__RtostreRttypesRvRwRuRtRR`R3RARR?RORRRRRRRRRRRRRRRRRRRRRRR%R&R'R(R)R*R+R,R-R.R/R0R1R2RR3R5R7R8R9R:R;R<R=R>R?R@RARBRCRDRERFRGRHRIRJRKRMRNRORPRQRRRSRTRRURVRWRXRYRRZR[R\R]R^R_R`RaRRRRbRcRdReRfRgRhRiRjRkRlRRRrRsRtRuRvRwRxRyRzR{R|R}R~RRRRRtnode_class_namesRRRRRRRRt ExceptionRR!R&R"R#RRtcompileRRRRRRc(RBRhR]R{RR'RR9RFRkRR2R%R.RR&RVRRRRR"R<R`RRTRCRMRR?RIRwRDR?RvR_RKRRRuR=R7R@RRbRRRwRAR~RzRR>RWR#R,RtReRERRPRR:RRRyRR`RR&RYRRRR3RfRRcRRuRiRSRJRR*RRRHR8RR3R|RRNRtR;RRRRURRxRRcRvRRRRRRrR^RXRRRRgRR)R\RjR[RGRsRRRRRRaR/R0RQRRARORRRZRRlR1RdRR(RRR5RR!R-RR+ROR}((Rt?s0    1 6|   A """E  ]            '