jfdZdZddlZddlmZddlmZGddeZGdd eZGd d ej Z dS) z' Transforms related to document parts. reStructuredTextN)nodes) Transformc&eZdZdZdZ dZddZdS) SectNumaS Automatically assigns numbers to the titles of document sections. It is possible to limit the maximum section level for which the numbers are added. For those sections that are auto-numbered, the "autonum" attribute is set, informing the contents table generator that a different form of the TOC should be used. ic|jjdd|_|jjdd|_|jjdd|_|jjdd|_|jj|j|j j j r4|jtj |_||j dS|j|j j _|j|j j _|j|j j _|j|j j _dS)Ndepthstartprefixsuffix) startnodedetailsgetmaxdepth startvaluer rparentremovedocumentsettings sectnum_xformsysmaxsizeupdate_section_numbers sectnum_depth sectnum_startsectnum_prefixsectnum_suffixselfs y/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/transforms/parts.pyapplyz SectNum.applys .227DAA .044Wa@@n,002>> n,002>>  $$T^444 = ! / @}$ #   ' ' 6 6 6 6 637=DM " 037?DM " 048KDM " 148KDM " 1 1 1rc|dz }|rd}n|j}|D]}t|tjr|t |fz}|d}tjd|jd|z|jzdzdg}| d|d|d<||j kr| ||||dz }dS) Nr rr .u   sectnum)classesauto) r isinstancersectionstr generatedr joinrinsertrr) r!noder r r(childnumberstitler.s r"rzSectNum.update_section_numbers/s    &GGoG  E%//  CLL?2a!Osxx'8'884;F'(&K)))  Q *** !f 4=((//wFFF1   r$N)r%r)__name__ __module__ __qualname____doc__default_priorityr#rr%r$r"rrsO.@@@ r$rc*eZdZdZdZdZddZdZdS) Contentsa This transform generates a table of contents from the entire document tree or from a single branch. It locates "section" elements and builds them into a nested bullet list, which is placed within a "topic" created by the contents directive. A title is either explicitly specified, taken from the appropriate language module, or omitted (local table of contents). The depth may be specified. Two-way references between the table of contents and section titles are generated (requires Writer support). This transform requires a startnode, which contains generation options and provides the location for the generated table of contents (the startnode is replaced by the table of contents "topic"). icjt|jjdd}|jj}d|vr|jjj}t |tjsUt |tjs;|j}t |tjst |tj;n|j}|jjdd|_ d|vr|d|_ n|jjj |_ |rJ|jjj ||jj|jdS||}t!|r|j|dS|jjj|jjdS)N use_latex_tocFlocalidsr backlinks)getattrrrrrrr+rr,toc_idr@ toc_backlinks attributesupdaterbuild_contentslen replace_self)r! toc_by_writerrrcontentss r"r#zContents.applyWs 6OO .( g  -4I!)U];; -$Y?? -&, ")U];; -$Y?? -  In+E215 ' ! !$[1DNN!]3ADN  K N ! , 3 3G < < < N ! ( ( 8 8 8 8 8**955H8}} K++H55555%,33DN4IJJJJJr$rc2|dz }d|D}g}|jjdtj}|D]"}|d}|d}||} t jddg| Rd|ddi} |j | d } t j dd| } t j d| } |j d vrE| t j&|j d kr| |d<n|j d kr |j|d<||kr|||}| |z } || $|r1t jdg|R}|r|dd|SgS)Nr cFg|]}t|tj|Sr%)r+rr,).0sects r" z+Contents.build_contents..us)MMMTZem-L-LMDMMMr$r rr*r refidr?z toc-entry)suggested_prefix)entrytoprRrSr)zauto-toc)rrrrrcopy_and_filterr referencerset_id paragraph list_itemr@ next_noderBrFappend bullet_list)r!r1levelsectionsentriesr r,r4r* entrytextrUref_idrRitemsubsectsrJs r"rFzContents.build_contentsss  MMTMMM&**7CK@@ ! !GAJE99V$$D,,U33IB4)2444genQ6G44I])));F*HHFOBI66E?2u--D"222OOEO44<>W,,%+E'NN^u,,%)[E'Nu}}..w>>  NN4  (6g666H 7#**:666OIr$c|t|j}|||S)z@Return a copy of a title, with references, images, etc. removed.)ContentsFilterr walkaboutget_entry_text)r!r1visitors r"rTzContents.copy_and_filters5 // w%%'''r$N)r)r5r6r7r8r9r#rFrTr%r$r"r;r;Es\  KKK8B(((((r$r;c8eZdZdZdZdZdZdZeZeZ eZ dS)rdc4|jSN) get_tree_copychildrenr s r"rfzContentsFilter.get_entry_texts!!##,,r$ctjrjrSkipNoder!r1s r"visit_citation_referencez'ContentsFilter.visit_citation_reference nr$ctjrjrnrps r"visit_footnote_referencez'ContentsFilter.visit_footnote_referencerrr$c|dr2|jtj|dtj)Nalt)hasattrrrZrTextrorps r" visit_imagezContentsFilter.visit_imagesB <<   8 K  uz$u+66 7 7 7nr$ctjrj)r SkipDeparturerps r" ignore_node_but_process_childrenz/ContentsFilter.ignore_node_but_process_childrens !!r$N) r5r6r7rfrqrtryr|visit_problematicvisit_reference visit_targetr%r$r"rdrdsk--- """96O3LLLr$rd) r8 __docformat__rdocutilsrdocutils.transformsrrr;TreeCopyVisitorrdr%r$r"rs #  ))))))11111i111hS(S(S(S(S(yS(S(S(l44444U*44444r$