a
    Sicî2  ã                   @   sš   d Z ddlZddlZddlZej d¡Zej e¡Z	ej
 e	¡ e	ejd< e d¡e	_e d¡e	_e	je	_e dej¡e	_e d¡ZG d	d
„ d
e	jƒZdS )aÚ  
Python Markdown

A Python implementation of John Gruber's Markdown.

Documentation: https://python-markdown.github.io/
GitHub: https://github.com/Python-Markdown/markdown/
PyPI: https://pypi.org/project/Markdown/

Started by Manfred Stienstra (http://www.dwerg.net/).
Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
Currently maintained by Waylan Limberg (https://github.com/waylan),
Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).

Copyright 2007-2020 The Python Markdown Project (v. 1.7 and later)
Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
Copyright 2004 Manfred Stienstra (the original version)

License: BSD (see LICENSE.md for details).
é    Nzhtml.parserÚ
htmlparserz\?>z&([a-zA-Z][-.a-zA-Z0-9]*);a”  
  <[a-zA-Z][^`\t\n\r\f />\x00]*       # tag name <= added backtick here
  (?:[\s/]*                           # optional whitespace before attribute name
    (?:(?<=['"\s/])[^`\s/>][^\s/=>]*  # attribute name <= added backtick here
      (?:\s*=+\s*                     # value indicator
        (?:'[^']*'                    # LITA-enclosed value
          |"[^"]*"                    # LIT-enclosed value
          |(?!['"])[^`>\s]*           # bare value <= added backtick here
         )
         (?:\s*,)*                    # possibly followed by a comma
       )?(?:\s|/(?!>))*
     )*
   )?
  \s*                                 # trailing whitespace
z^([ ]*\n){2}c                       sØ   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡ fdd„Zedd	„ ƒZd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Z‡ fd$d%„Z‡ fd&d'„Zd(Zd)d*„ Zd+d,„ Z‡  ZS )-ÚHTMLExtractorzÅ
    Extract raw HTML from text.

    The raw HTML is stored in the `htmlStash` of the Markdown instance passed
    to `md` and the remaining text is stored in `cleandoc` as a list of strings.
    c                    s8   d|vrd|d< t dgƒ| _tƒ j|i |¤Ž || _d S )NÚconvert_charrefsFÚhr)ÚsetÚ
empty_tagsÚsuperÚ__init__Úmd)Úselfr
   ÚargsÚkwargs©Ú	__class__© úO/var/www/html/django/DPS/env/lib/python3.9/site-packages/markdown/htmlparser.pyr	   H   s
    zHTMLExtractor.__init__c                    s,   d| _ d| _g | _g | _g | _tƒ  ¡  dS )z1Reset this instance.  Loses all unprocessed data.FN)ÚinrawÚintailÚstackÚ_cacheÚcleandocr   Úreset©r   r   r   r   r   S   s    zHTMLExtractor.resetc                    sr   t ƒ  ¡  t| jƒr@| jr4| js4|  t | j¡¡ n|  | j¡ t| j	ƒrn| j
 | jj d | j	¡¡¡ g | _	dS )zHandle any buffered data.Ú N)r   ÚcloseÚlenÚrawdatar   Ú
cdata_elemÚhandle_datar   Úunescaper   r   Úappendr
   Ú	htmlStashÚstoreÚjoinr   r   r   r   r   \   s    


zHTMLExtractor.closec                 C   sJ   | j dkrFd| jv rFt d | j d ¡| j¡}|r:| ¡ S | j d¡S dS )zFReturns char index in self.rawdata for the start of the current line. é   Ú
z([^\n]*\n){{{}}}r   )Úlinenor   ÚreÚmatchÚformatÚendÚrfind)r   Úmr   r   r   Úline_offsetk   s    zHTMLExtractor.line_offsetc                 C   s<   | j dkrdS | j dkrdS | j| j| j| j  …  ¡ dkS )z†
        Returns True if current position is at start of line.

        Allows for up to three blank spaces at start of line.
        r   Té   Fr   )Úoffsetr   r-   Ústripr   r   r   r   Úat_line_startx   s
    

zHTMLExtractor.at_line_startc                 C   s@   | j | j }tj | j|¡}|r2| j|| ¡ … S d |¡S dS )z™
        Returns the text of the end tag.

        If it fails to extract the actual text from the raw data, it builds a closing tag with `tag`.
        z</{}>N)r-   r/   r   Ú	endendtagÚsearchr   r*   r)   )r   ÚtagÚstartr,   r   r   r   Úget_endtag_text…   s
    zHTMLExtractor.get_endtag_textc                 C   s–   || j v r|  ||¡ d S | j |¡rL| js:|  ¡ rL| jsLd| _| j d¡ |  	¡ }| jrt| j
 |¡ | j |¡ n| j |¡ || jv r’|  ¡  d S )NTr%   )r   Úhandle_startendtagr
   Úis_block_levelr   r1   r   r   r    Úget_starttag_textr   r   ÚCDATA_CONTENT_ELEMENTSÚclear_cdata_mode)r   r4   ÚattrsÚtextr   r   r   Úhandle_starttag”   s    
 
zHTMLExtractor.handle_starttagc                 C   sÌ   |   |¡}| jr¼| j |¡ || jv r>| jr>| j ¡ |kr&q>q&t| jƒdkrÈt | j	| j
| j t|ƒ d … ¡r~| j d¡ nd| _d| _| j | jj d | j¡¡¡ | j d¡ g | _n| j |¡ d S )Nr   r%   TFr   ú

)r6   r   r   r    r   Úpopr   Úblank_line_rer(   r   r-   r/   r   r   r
   r!   r"   r#   )r   r4   r=   r   r   r   Úhandle_endtag©   s     

$zHTMLExtractor.handle_endtagc                 C   s8   | j rd|v rd| _ | jr(| j |¡ n| j |¡ d S )Nr%   F)r   r   r   r    r   ©r   Údatar   r   r   r   Ä   s
    zHTMLExtractor.handle_datac                 C   sÂ   | j s| jr| j |¡ n¤|  ¡ r²|r²t | j| j| j	 t
|ƒ d… ¡rT|d7 }nd| _| jrj| jd nd}| d¡sŽ| d¡rŽ| j d¡ | j | jj |¡¡ | j d¡ n| j |¡ dS )z Handle empty tags (`<data>`). Nr%   Téÿÿÿÿr   r?   )r   r   r   r    r1   rA   r(   r   r-   r/   r   r   Úendswithr
   r!   r"   )r   rD   Úis_blockÚitemr   r   r   Úhandle_empty_tagÌ   s    $
zHTMLExtractor.handle_empty_tagc                 C   s   | j |  ¡ | j |¡d d S )N©rG   )rI   r9   r
   r8   )r   r4   r<   r   r   r   r7   ã   s    z HTMLExtractor.handle_startendtagc                 C   s   | j d |¡dd d S )Nz&#{};FrJ   ©rI   r)   ©r   Únamer   r   r   Úhandle_charrefæ   s    zHTMLExtractor.handle_charrefc                 C   s   | j d |¡dd d S )Nz&{};FrJ   rK   rL   r   r   r   Úhandle_entityrefé   s    zHTMLExtractor.handle_entityrefc                 C   s   | j d |¡dd d S )Nz	<!--{}-->TrJ   rK   rC   r   r   r   Úhandle_commentì   s    zHTMLExtractor.handle_commentc                 C   s   | j d |¡dd d S )Nz<!{}>TrJ   rK   rC   r   r   r   Úhandle_declï   s    zHTMLExtractor.handle_declc                 C   s   | j d |¡dd d S )Nz<?{}?>TrJ   rK   rC   r   r   r   Ú	handle_piò   s    zHTMLExtractor.handle_pic                 C   s,   |  d¡rdnd}| jd ||¡dd d S )NzCDATA[z]]>z]>z<![{}{}TrJ   )Ú
startswithrI   r)   )r   rD   r*   r   r   r   Úunknown_declõ   s    zHTMLExtractor.unknown_declc                    s,   |   ¡ s| jrtƒ  |¡S |  d¡ |d S )Nz<?é   )r1   r   r   Úparse_pir   ©r   Úir   r   r   rV   ù   s    
zHTMLExtractor.parse_pic                    s,   |   ¡ s| jrtƒ  |¡S |  d¡ |d S )Nz<!rU   )r1   r   r   Úparse_html_declarationr   rW   r   r   r   rY     s    
z$HTMLExtractor.parse_html_declarationNc                 C   s   | j S )z)Return full source of start tag: '<...>'.)Ú_HTMLExtractor__starttag_textr   r   r   r   r9     s    zHTMLExtractor.get_starttag_textc                 C   sò  d | _ |  |¡}|dk r|S | j}|||… | _ g }tj ||d ¡}|sRJ dƒ‚| ¡ }| d¡ ¡  | _	}||k r4tj
 ||¡}|sŽq4| ddd¡\}	}
}|
s¬d }n\|d d… d  krÐ|dd … ksün |d d… d  krø|dd … krn n|dd… }|rt |¡}| |	 ¡ |f¡ | ¡ }qn|||…  ¡ }|d	vr²|  ¡ \}}d
| j v rŽ|| j  d
¡ }t| j ƒ| j  d
¡ }n|t| j ƒ }|  |||… ¡ |S | d¡rÌ|  ||¡ n"|| jv râ|  |¡ |  ||¡ |S )Nr   r$   z#unexpected call to parse_starttag()rU   r.   ú'rE   ú")ú>ú/>r%   r^   )rZ   Úcheck_for_whole_start_tagr   r   Útagfind_tolerantr(   r*   ÚgroupÚlowerÚlasttagÚattrfind_tolerantr   r    r0   ÚgetposÚcountr   r+   r   rF   r7   r:   Úset_cdata_moder>   )r   rX   Úendposr   r<   r(   Úkr4   r,   ÚattrnameÚrestÚ	attrvaluer*   r&   r/   r   r   r   Úparse_starttag  sZ    

&ÿ
ÿ



ÿ
zHTMLExtractor.parse_starttag)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   Úpropertyr-   r1   r6   r>   rB   r   rI   r7   rN   rO   rP   rQ   rR   rT   rV   rY   rZ   r9   rm   Ú__classcell__r   r   r   r   r   @   s0   	
r   )rq   r'   Úimportlib.utilÚ	importlibÚsysÚutilÚ	find_specÚspecÚmodule_from_specr   ÚloaderÚexec_moduleÚmodulesÚcompileÚpicloseÚ	entityrefÚ
incompleteÚVERBOSEÚlocatestarttagend_tolerantrA   Ú
HTMLParserr   r   r   r   r   Ú<module>   s   
ò
