
    $g                         d Z ddlmZ ddlmZmZ ddlmZ ddlmZ dZ	dZ
dZd	Zd
Z G d de          Z G d de          Zd ZdS )av  
EscapeAll.

pymdownx.escapeall
Escape everything.

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)InlineProcessorSubstituteTagInlineProcessor)util   z\\(.)z	\\([^\n])z\\\nc                       e Zd ZdZd Zd ZdS )EscapeAllPatternzReturn an escaped character.c                 @    || _         t          j        | ||           dS )Initialize.N)nbspr   __init__)selfpatternr   mds       R/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/escapeall.pyr   zEscapeAllPattern.__init__)   s&     	 w33333    c                    |                     d          }|dv r:|dk    rd}n|dk    rd}n|dk    rd}| j        j                            |          }n}| j        r&|d	k    r | j        j                            d
          }nP|t
          t          fv r|}n=d                    t          j        t          j
        |          t          j                  }||                    d          |                    d          fS )z)Convert the char to an escaped character.r   )<>&r   z&lt;r   z&gt;r   z&amp; z&nbsp;z{}{}{}r   )groupr   	htmlStashstorer   STXETXformatmd_utilr   get_ordstartend)r   mdatacharescapes        r   handleMatchzEscapeAllPattern.handleMatch/   s     wwqzz?""s{{W&,,T22FFY 	S43;;W&,,X66FFc3ZFF__W[$,t2D2DgkRRFqwwqzz15588++r   N)__name__
__module____qualname____doc__r   r(    r   r   r   r   &   s8        &&4 4 4, , , , ,r   r   c                   (     e Zd ZdZ fdZd Z xZS )EscapeAllExtensionz/Extension that allows you to escape everything.c                 V    ddgddgd| _          t                      j        |i | dS )r   Fz4Turn escaped newlines to hardbreaks - Default: Falsez;Turn escaped spaces to non-breaking spaces - Default: False)	hardbreakr   N)configsuperr   )r   argskwargs	__class__s      r   r   zEscapeAllExtension.__init__G   sO    
 F
 M	
 	
 	$)&)))))r   c                 .   |                                  }|d         }|j                            t          |rt          nt
          |d         |          dd           |d         r1|j                            t          t          d          dd           dS dS )zEscape all.r1   r   r'      brgffffff@N)
getConfigsinlinePatternsregisterr   ESCAPE_NO_NL_RE	ESCAPE_REr   HARDBREAK_RE)r   r   r2   r1   s       r   extendMarkdownz!EscapeAllExtension.extendMarkdownV   s     "";'	
""	H__y&QW.Z\]]	
 	
 	
 + 	k&&'CLRV'W'WYdfijjjjj	k 	kr   )r)   r*   r+   r,   r   r@   __classcell__)r6   s   @r   r/   r/   D   sT        99* * * * *k k k k k k kr   r/   c                      t          | i |S )zReturn extension.)r/   )r4   r5   s     r   makeExtensionrC   e   s     t.v...r   N)r,   markdownr   markdown.inlinepatternsr   r   r   r     r   r   r>   r=   r?   r   r/   rC   r-   r   r   <module>rG      s    0       Q Q Q Q Q Q Q Q $ $ $ $ $ $       	, , , , , , , ,<k k k k k k k kB/ / / / /r   