
    $gH                     z    d Z ddlmZ ddlmZ ddlmc mZ ddlZ G d de          Z	 G d de          Z
d	 ZdS )
a_  
Details.

pymdownx.details

MIT license.

Copyright (c) 2017 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )	Extension)BlockProcessorNc                   z     e Zd ZdZ ej        d          Z ej        d          Z fdZd Z	d Z
d Zd Z xZS )	DetailsProcessorzDetails block processor.za(?:^|\n)\?{3}(\+)? ?(?:([\w\-]+(?: +[\w\-]+)*?)?(?: +"(.*?)")|([\w\-]+(?: +[\w\-]+)*?)) *(?:\n|$)z {2,}c                 f    t                                          |           d| _        d| _        dS )zInitialization.Nr   )super__init__current_siblingcontent_indention)selfparser	__class__s     P/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/details.pyr	   zDetailsProcessor.__init__&   s3     	   #!"    c                 x   g }|                     d          }|D ]b}|                    d|z            r|                    ||d                    8|                                s|                    d           b d                    |          d                    |t          |          d                   fS )z;Remove a tab from the front of each line of the given text.
 N )split
startswithappendstripjoinlen)r   textlengthnewtextlineslines         r   detab_by_lengthz DetailsProcessor.detab_by_length.   s     

4   	 	DsV|,, tFGG}----ZZ\\ r""""yy!!499U3w<<==-A#B#BBBr   c                    |}d}| j         8| j         }|                     || j                  \  }}d| _         d| _        |||fS |                     |          }||j                                        dk    rd}n|                     |          }d}|y|s|                    d| j        z  dz            rS|Q|j        dv rH|                     |          }||                     |          nd}|| j        d         }|| j        z  }nd}|y|                    d| j        z            sd}|1|| j        z  }|                     ||          \  }}|| _         || _        |||fS )z
        Get sibling details.

        Retrieve the appropriate sibling element. This can get tricky when
        dealing with lists.

        r   Nr   detailsr      )uloldl)r
   r    content_indent	lastChildtaglowerr   
tab_length)r   parentblock	old_blocknon_detailssibling
last_childindents           r   parse_contentzDetailsProcessor.parse_content<   s    	 +*G!%!5!5eT=P!Q!QE;#'D "#DE;....((?gk//11Y>>GG 00JF('E,<,<S4?=RUV=V,W,W'*z~AS/S/S
 #nnZ88G<C<O!8!8!8UYJ
 "$/"2"23Edo-FF!%J# (& ##C$/$9:: "$/)%)%9%9)V%L%L"{'.$&,#{**r   c                 v    | j                             |          rdS |                     ||          d         duS )zTest block.Tr   N)STARTsearchr3   )r   r,   r-   s      r   testzDetailsProcessor.testw   sB     :U## 	D4%%fe44Q7tCCr   c                    |                     d          }| j                            |          }|r|                                dk    r6| j                            ||d|                                         g           ||                                d         }|                     |          \  }}n|                     ||          \  }}}|rH|	                    d          }|du}|	                    d          rn| j
                            d|	                    d                                                    }	|	                    d          d                                         }
n[|	                    d          }|dn,| j
                            d|                                          }	|	                    d          }
t          j        |d	|rd
d
ini           }|	r|                    d|	           t          j        |d          }|
|_        n<|j        dv r1|j        r*|j        }d|_        t          j        |d          }||_        |}| j                            ||           |r|                    d|           dS dS )z!Convert to details/summary block.r   N      r   r#   r      r"   openclasssummary)liddp)popr5   r6   startr   parseBlocksenddetabr3   groupCOMPRESS_SPACESsubr*   r   
capitalizeetree
SubElementsetr   r)   
parseChunkinsert)r   r,   blocksr-   mr/   r0   stateis_open
class_nametitleclassesdivr>   r   rA   s                   r   runzDetailsProcessor.run   sk    

1Je$$ 	Lwwyy1}}''z		z1B0CDDD!%%''((OE!%E!2!2E;;*.*<*<VU*K*K'GUK 	GGAJJE4'Gwwqzz #!155c1771::;K;K;M;MNN
"((--a0;;==''!**#*?RR8L8P8PQTV]VcVcVeVe8f8f


"6977Z7G7GXZ\\C -,,,&sI66G GLL {l**w|*|!$Wc22CsE*** 	*MM![)))))	* 	*r   )__name__
__module____qualname____doc__recompiler5   rH   r	   r    r3   r7   rX   __classcell__)r   s   @r   r   r      s        ""BJl E !bj**O# # # # #C C C9+ 9+ 9+vD D D.* .* .* .* .* .* .*r   r   c                       e Zd ZdZd ZdS )DetailsExtensionzAdd Details extension.c                     |                     |            |j        j                            t	          |j                  dd           dS )z!Add Details to Markdown instance.r"   i   N)registerExtensionr   blockprocessorsregisterr   )r   mds     r   extendMarkdownzDetailsExtension.extendMarkdown   sE    
T"""
	!**+;BI+F+F	SVWWWWWr   N)rY   rZ   r[   r\   rh    r   r   ra   ra      s.          X X X X Xr   ra   c                      t          | i |S )zReturn extension.)ra   )argskwargss     r   makeExtensionrm      s     T,V,,,r   )r\   markdownr   markdown.blockprocessorsr   xml.etree.ElementTreerK   ElementTreer]   r   ra   rm   ri   r   r   <module>rr      s    .       3 3 3 3 3 3 % % % % % % % % % 				O* O* O* O* O*~ O* O* O*dX X X X Xy X X X- - - - -r   