
    $g3                         d Z ddlmZ ddlmZ ddlmZ ddlmZ dZdZ	dZ
d	Zd
ZdZddd fZddd fZddd fZee	e
eeeeeed	Zddddddddddd d!d"d#d$d%Zd&d'd(d)Z G d* d+e          Z G d, d-e          Zd. Zd/S )0a  
Smart Symbols.

pymdownx.smartsymbols
Really simple plugin to add support for:
  copyright, trademark, and registered symbols
  plus/minus, not equal, arrows via:

    copyright  = `(c)`
    trademark  = `(tm)`
    registered = `(r)`
    plus/minus = `+/-`
    care/of    = `c/o`
    fractions  = `1/2` etc.
        (only certain available unicode fractions)
    arrows:
        left   = `<--`
        right  = `-->`
        both   = `<-->`
    not equal  = `=/=`
       (maybe this could be =/= in the future as this might be more
        intuitive to non-programmers)

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)treeprocessors)Registry)HtmlInlineProcessor)zsmart-trademarkz\(tm\)z&trade;)zsmart-copyrightz\(c\)z&copy;)zsmart-registeredz\(r\)z&reg;)zsmart-plus-minusz\+/-z&plusmn;)zsmart-not-equalz=/=z&ne;)zsmart-care-ofz\bc/o\bz&#8453;zsmart-ordinal-numberszn(?x)
    \b
    (?P<leading>(?:[1-9][0-9]*)?)
    (?P<tail>(?<=1)(?:1|2|3)th|1st|2nd|3rd|[04-9]th)
    \b
    c                     d                     |                     d          r|                     d          nd|                     d          d d         |                     d          dd                    S )Nz{}{}<sup>{}</sup>leading tail   )formatgroupms    U/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/smartsymbols.py<lambda>r   =   sg    !((ggi008	b	aggfooabb1      zsmart-arrowsz-(?P<arrows>\<-{2}\>|(?<!-)-{2}\>|\<-{2}(?!-))c                 B    t           |                     d                   S )Narrows)ARRr   r   s    r   r   r   E   s    c!''(##$ r   zsmart-fractionszW(?<!\d)(?P<fractions>1/4|1/2|3/4|1/3|2/3|1/5|2/5|3/5|4/5|1/6|5/6|1/8|3/8|5/8|7/8)(?!\d)c                 B    t           |                     d                   S )N	fractions)FRACr   r   s    r   r   r   J   s    d177;''( r   		trademark	copyright
registered	plusminusr   notequalr   ordinal_numberscare_ofz&frac14;z&frac12;z&frac34;z&#8531;z&#8532;z&#8533;z&#8534;z&#8535;z&#8536;z&#8537;z&#8538;z&#8539;z&#8540;z&#8541;z&#8542;)z1/4z1/2z3/4z1/3z2/3z1/5z2/5z3/5z4/5z1/6z5/6z1/8z3/8z5/8z7/8z&rarr;z&larr;z&harr;)z-->z<--z<-->c                   (     e Zd ZdZ fdZd Z xZS )SmartSymbolsPatternzSmart symbols patterns handler.c                 Z    t                                          ||           || _        dS )zSetup replace pattern.N)super__init__replace)selfpatternr'   md	__class__s       r   r&   zSmartSymbolsPattern.__init__u   s*     	"%%%r   c                    | j         j                            |                    t	          | j                  r|                     |          n| j                            |                    d          |                    d          fS )zReplace symbol.r   )r*   	htmlStashstoreexpandcallabler'   startend)r(   r   datas      r   handleMatchzSmartSymbolsPattern.handleMatch{   sm     w &&HH(>(>PT\\!___DLQQ
 
771::quuQxx  	 r   )__name__
__module____qualname____doc__r&   r4   __classcell__r+   s   @r   r#   r#   r   sM        ))                 r   r#   c                   .     e Zd ZdZ fdZd Zd Z xZS )SmartSymbolsExtensionzSmart Symbols extension.c           
          ddgddgddgddgddgddgddgdd	gdd
gd	| _          t                      j        |i | dS )z*Setup config of which symbols are enabled.T	Trademark	Copyright
Registeredz
Plus/MinusArrowsz	Not Equal	FractionszOrdinal NumberszCare/ofr   N)configr%   r&   )r(   argskwargsr+   s      r   r&   zSmartSymbolsExtension.__init__   s     ,,.-X&{+, $&78i(

 

 	$)&)))))r   c                     | j                             t          |d         |d         |          |d         d           dS )z$Construct the inline symbol pattern.r      r      N)patternsregisterr#   )r(   rI   r*   s      r   add_patternz!SmartSymbolsExtension.add_pattern   sA     	28A;RPPRZ[\R]_abbbbbr   c                 F   |                                  }t                      | _        t                                          D ]#\  }}||         r|                     ||           $t          j        |          }| j        |_        |j        	                    |dd           dS )zGCreate a dict of inline replace patterns and add to the tree processor.zsmart-symbolsgffffff@N)

getConfigsr   rI   REPLitemsrK   r   InlineProcessorinlinePatternsrJ   )r(   r*   configskvinline_processors         r   extendMarkdownz$SmartSymbolsExtension.extendMarkdown   s     //## 

JJLL 	( 	(DAqqz (  B''')9"==*.-'
""#3_cJJJJJr   )r5   r6   r7   r8   r&   rK   rV   r9   r:   s   @r   r<   r<      sf        ""* * * * * c c c
K K K K K K Kr   r<   c                      t          | i |S )zReturn extension.)r<   )rD   rE   s     r   makeExtensionrX      s     !$1&111r   N)r8   markdownr   r   markdown.utilr   markdown.inlinepatternsr   RE_TRADERE_COPYRE_REGRE_PLUSMINUSRE_NOT_EQUAL
RE_CARE_OFRE_ORDINAL_NUMBERS	RE_ARROWSRE_FRACTIONSrN   r   r   r#   r<   rX    r   r   <module>rf      s  ( (R       # # # # # # " " " " " " 7 7 7 7 7 75
2	1936
   4$$	 ^(( )
 
  &           -      "$K $K $K $K $KI $K $K $KN2 2 2 2 2r   