
    $gR                         d Z ddlmZ ddlmZ ddlZ ej        dej        ej        z            Z	dZ
 G d de          Z G d	 d
e          Zd ZdS )a  
Strip HTML (previously named Plain HTML).

pymdownx.striphtml
An extension for Python Markdown.
Strip classes, styles, and ids from html

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)PostprocessorNaB  (?x)
    (?:
        (?P<comments>(?:\r?\n?\s*)<!--(?:-(?!->)|[^-])*?-->(?:\s*)(?=\r?\n)|<!--[\s\S]*?-->)|
        (?P<scripts>
            (?P<script_open><(?P<script_name>style|script))
            (?P<script_attr>(?:\s+[\w\-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'`=<>]+))?)*)
            (?P<script_rest>\s*>.*?</(?P=script_name)\s*>)
        )|
        (?P<open><(?P<name>[\w\:\.\-]+))
        (?P<attr>(?:\s+[\w\-:]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'`=<>]+))?)*)
        (?P<close>\s*(?P<self_close>/)?>)|
        (?P<close_tag></(?P<close_name>[\w\:\.\-]+)\s*>)
    )
    zf(?x)
(?P<attr>
    (?:
        \s+(?:%s)
        (?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'`=<>]+))
    )*
)
c                   .     e Zd ZdZ fdZd Zd Z xZS )StripHtmlPostprocessorz-Post processor to strip out unwanted content.c                 H   || _         d| _        d |D             }|r|                    d           |rLt          j        t
          d                    |          z  t          j        t          j        z            | _        t                      
                    |           dS )Initialize.Nc                 Z    g | ](}t          j        |                                          )S  )reescapestrip).0as     R/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/striphtml.py
<listcomp>z3StripHtmlPostprocessor.__init__.<locals>.<listcomp>C   s*    EEEqbi		**EEE    zon[\w]+|)strip_commentsre_attributesappendr   compileTAG_BAD_ATTRjoinDOTALLUNICODEsuper__init__)selfr   strip_js_on_attributesstrip_attributesmd
attributes	__class__s         r   r   zStripHtmlPostprocessor.__init__>   s     -!EE4DEEE
! 	*j))) 	!#sxx
333	BJ&" "D
 	r   c                    |                     d          r | j        rdn|                     d          }n=|                     d          r|                     d          }| j        2|| j                            d|                     d                    z  }n||                     d          z  }||                     d          z  }n|                     d          r|                     d	          }n~|                     d
          }| j        2|| j                            d|                     d                    z  }n||                     d          z  }||                     d          z  }|S )z)Replace comments and unwanted attributes.comments scriptsscript_openNscript_attrscript_rest	close_tagr   openattrclose)groupr   r   sub)r   mtags      r   replzStripHtmlPostprocessor.replN   sS    77: 	(+D""1D1DCCwwy!! (ggm,,%14-11"aggm6L6LMMMCC177=111Cqww}---%% (ggajjggfoo%14-11"aggfooFFFCC1776??*Cqwww'''
r   c                 t    | j         p| j        p| j        }|r t                              | j        |          n|S )z7Strip out ids and classes for a simplified HTML output.)r   r   r   RE_TAG_HTMLr0   r3   )r   textr   s      r   runzStripHtmlPostprocessor.runf   s<     #Xt'BXdFX38B{ty$///dBr   )__name__
__module____qualname____doc__r   r3   r7   __classcell__r#   s   @r   r   r   ;   sc        77       0C C C C C C Cr   r   c                   (     e Zd ZdZ fdZd Z xZS )StripHtmlExtensionzStripHTML extension.c                 \    ddgg dgddgd| _          t                      j        |i | dS )r   Tz=Strip HTML comments at the end of processing. - Default: TruezGA string of attributes separated by spaces.- Default: 'id class style']zHStrip JavaScript script attribues with the pattern on*.  - Default: True)r   r    r   N)configr   r   )r   argskwargsr#   s      r   r   zStripHtmlExtension.__init__p   sb    
 " /! #'
 
" 	$)&)))))r   c                 &   |                     |            |                                 }t          |                    d          |                    d          |                    d          |          }|j                            |dd           dS )z/Strip unwanted HTML attributes and/or comments.r   r   r    z
strip-html   N)registerExtension
getConfigsr   getpostprocessorsregister)r   r!   rA   	striphtmls       r   extendMarkdownz!StripHtmlExtension.extendMarkdown   s     	T"""""*JJ'((JJ/00JJ)**	
 
	 	""9lA>>>>>r   )r8   r9   r:   r;   r   rL   r<   r=   s   @r   r?   r?   m   sM        * * * * *,? ? ? ? ? ? ?r   r?   c                      t          | i |S )zReturn extension.)r?   )rB   rC   s     r   makeExtensionrN      s     t.v...r   )r;   markdownr   markdown.postprocessorsr   r   r   r   r   r5   r   r   r?   rN   r
   r   r   <module>rQ      s    2       1 1 1 1 1 1 				 bj I
 $/C /C /C /C /C] /C /C /Cd$? $? $? $? $? $? $? $?N/ / / / /r   