
    $g                         d Z ddlmZ ddlmZ ddlZ ej        dej                  ZddZ	 G d d	e          Z
 G d
 de          Zd ZdS )a  
Tasklist.

pymdownx.tasklist
An extension for Python Markdown.
Github style tasklists

MIT license.

Copyright (c) 2014 - 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)TreeprocessorNz:^(?P<checkbox> *\[(?P<state>(?:x|X| ){1})\] +)(?P<line>.*)Fc                     |r:dd                     |sdnd|                                 dk    rdnd          z   dz   S d                     |sdnd|                                 dk    rdnd          S )	zGet checkbox tag.z!<label class="task-list-control">z<input type="checkbox"{}{}/>z	 disabled xz checkedz2<span class="task-list-indicator"></span></label> z<input type="checkbox"{}{}/> )formatlower)statecustom_checkboxclickable_checkboxs      Q/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/tasklist.pyget_checkboxr   !   s      
/*11#5=2#kkmms22

< << A	A	
 +11-52kkmms**

4 4 4    c                   4     e Zd ZdZ fdZd Zd Zd Z xZS )TasklistTreeprocessorz9Tasklist tree processor that finds lists with checkboxes.c                 J    t                                          |           dS )Initialize.N)super__init__)selfmd	__class__s     r   r   zTasklistTreeprocessor.__init__4   s#     	r   c                    d}t                               |j                  }|h| j        j                            t          |                    d          | j        | j	                            |                    d          z   |_        d}|S )z)Search for checkbox directly in `li` tag.FNr
   lineT)
RE_CHECKBOXmatchtextr   	htmlStashstorer   groupr   r   )r   lifoundms       r   inlinezTasklistTreeprocessor.inline9   s~     bg&&=g'--QWWW--t/CTE\]]  BG Er   c                    d}t          |          rt          t          |                    }|j        dk    r|j        t
                              |j                  }|h| j        j        	                    t          |                    d          | j        | j                            |                    d          z   |_        d}|S )z%Search for checkbox in sub-paragraph.FpNr
   r   T)lennextitertagr   r   r   r   r   r   r   r    r   r   )r   r!   r"   firstr#   s        r   sub_paragraphz#TasklistTreeprocessor.sub_paragraphE   s     r77 	!bNNEyCEJ$:%%ej11=!%!2!8!8$QWWW%5%5t7KTMdee" ""(EJ !Er   c                 d   t          | j        d                   | _        t          | j        d                   | _        d |                                D             }g }|                    d          }|D ]}|j        |j        dk    r|                     |          s*n|                     |          sA|j        	                    dd          }|dk    rg n|
                                }|                    d           d	                    |          |j        d<   |                    |           |D ]w}||         }|j        	                    dd          }|dk    rg n|
                                }d
|vr|                    d
           d	                    |          |j        d<   x|S )z2Find list items that start with [ ] or [x] or [X].r   r   c                     i | ]
}|D ]}||S  r/   ).0r&   cs      r   
<dictcomp>z-TasklistTreeprocessor.run.<locals>.<dictcomp>Y   s'    ;;;q;;Aa;;;;r   r!   Nr   classztask-list-item 	task-list)boolconfigr   r   r)   r   r,   r$   attribgetsplitappendjoin)	r   root
parent_map
task_itemslilinksr!   r1   classesparents	            r   runzTasklistTreeprocessor.runT   s     $DK0A$BCC"&t{3G'H"I"I;;DIIKK;;;

))D// 	" 	"Bw"'R--))"-- [[__  	gr**AGGbbGNN+,,,!$'!2!2BIgb!!!! 	7 	7B^F!!'2..AGGbbG')){+++%(XXg%6%6FM'""r   )	__name__
__module____qualname____doc__r   r$   r,   rC   __classcell__r   s   @r   r   r   1   sk        CC    

 
 
        r   r   c                   (     e Zd ZdZ fdZd Z xZS )TasklistExtensionzTasklist extension.c                 b    ddgddgddgddgd| _          t                      j        |i | dS )	r   FzWAdd an empty label tag after the input tag to allow for custom styling - Default: Falsez9Allow user to check/uncheck the checkbox - Default: FalseTzEnable delete - Default: Truez Enable subscript - Default: True)r   r   delete	subscriptN)r7   r   r   )r   argskwargsr   s      r   r   zTasklistExtension.__init__w   sc    
 i 
 K# <= BC
 
 	$)&)))))r   c                     t          |          }|                                 |_        |j                            |dd           |                    |            dS )z2Add checklist tree processor to Markdown instance.r5      N)r   
getConfigsr7   treeprocessorsregisterregisterExtension)r   r   tasklists      r   extendMarkdownz TasklistExtension.extendMarkdown   sW     ),,//++
""8["===
T"""""r   )rD   rE   rF   rG   r   rX   rH   rI   s   @r   rK   rK   t   sM        * * * * *$# # # # # # #r   rK   c                      t          | i |S )zReturn extension.)rK   )rO   rP   s     r   makeExtensionrZ      s     d-f---r   )FF)rG   markdownr   markdown.treeprocessorsr   recompileDOTALLr   r   r   rK   rZ   r/   r   r   <module>r`      s    2       1 1 1 1 1 1 				bjVXZXabb4 4 4 4 @ @ @ @ @M @ @ @F# # # # #	 # # #<. . . . .r   