Files
intellecton/venv/lib/python3.12/site-packages/markdown/__pycache__/htmlparser.cpython-312.pyc
T

102 lines
20 KiB
Plaintext
Raw Normal View History

Ë
jÔCãódZddlmZddlZddlZddlZddlmZm Z erddl
m Z ejd«Z
ejjd«Zejj#e«Zej&j)e«eej*d<ejd «e_ejd
«e_ejd «e_ejd «e_ej2e_ejd
ej6«e_ejdej6«e_ejd«ZGddej>«Z e e_Gddej>«Z!y)a 
This module imports a copy of [`html.parser.HTMLParser`][] and modifies it heavily through monkey-patches.
A copy is imported rather than the module being directly imported as this ensures that the user can import
and use the unmodified library for their own needs.
é)Ú annotationsN)Ú
TYPE_CHECKINGÚSequence)ÚMarkdownz--!?>z html.parserÚ
htmlparserz
<[a-zA-Z]|</>z </[a-zA-Z]?z\?>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
a
[a-zA-Z][^`\t\n\r\f />]* # tag name
[\t\n\r\f /]* # optional whitespace before attribute name
(?:(?<=['"\t\n\r\f /])[^`\t\n\r\f />][^\t\n\r\f /=>]* # attribute name
(?:= # value indicator
(?:'[^']*' # LITA-enclosed value
|"[^"]*" # LIT-enclosed value
|(?!['"])[^>\t\n\r\f ]* # bare value
)
)?
[\t\n\r\f /]* # possibly followed by a space
)*
>?
z ^([ ]*\n){2}có.eZdZdZˆfdZdˆfd ZˆxZS)Ú _HTMLParserz"Handle special start and end tags.cóþ|j||dz}t|d«}t|«dksd|cxkrdks5nd|cxkrdks(n|j|j||dz«|dzSt||«S)éÿÿÿÿéAéZéaézé)ÚrawdataÚordÚlenÚ handle_dataÚsuperÚ parse_endtag)ÚselfÚstartÚcÚ __class__s €úV/home/antigravity/intellecton/venv/lib/python3.12/site-packages/markdown/htmlparser.pyrz_HTMLParser.parse_endtagcsyø€Ø ˜Q˜q ™sÐÜ b‘ ‹NˆÜ ˆu:˜Š> ¤-¨R¤-°2¸´>¸c´ × Ñ ˜TŸ\™\¨!¨A°©EÐ q5ˆ‰wÑ# có˜|j||dzdk(r&|j|j||dz«|dzSt|
|«S)Nr ú</>)rrrÚparse_starttag©rrrs €rr!z_HTMLParser.parse_starttagksPø€à <‰<˜˜!˜a™%Ð   × Ñ ˜TŸ\™\¨!¨A°©EÐ q‘5ˆ‰wÑ% (r©rÚintÚreturnr$)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rr!Ú
__classcell__©rs@rr r `sø„Ù)rr cóeZdZUdZdˆfd ZˆfdZˆfdZedd«ZddZ ddZ
d dZ d!d „Z d"d
Z
d#d Zd!d Zd$d
Zd$dZd"dZd"dZd"dZd"dZd%ˆfd Zd&dZd%ˆfd Zd'd(ˆfd
ZdZded<d)dZd%dZˆxZS)*Ú
HTMLExtractorzû
Extract raw HTML from text.
The raw HTML is stored in the [`htmlStash`][markdown.util.HtmlStash] of the
[`Markdown`][markdown.Markdown] instance passed to `md` and the remaining text
is stored in `cleandoc` as a list of strings.
cóvd|vrd|d<tdg«|_dg|_t||i|¤Ž||_y)convert_charrefsFÚhrr)ÚsetÚ
empty_tagsÚlineno_start_cacherÚ__init__Úmd)rr5ÚargsÚkwargsrs €rr4zHTMLExtractor.__init__sJø€Ø   +Ø).ˆ ˜t˜f+ˆŒà#$ #ˆÔô ј) &Òˆrcóxd|_d|_g|_g|_g|_dg|_t |«y)z1Reset this instance. Loses all unprocessed data.FrN)ÚinrawÚintailÚstackÚ_cacheÚcleandocr3rÚreset©rrs €rr>zHTMLExtractor.resetŽs9ø€àˆŒ
؈Œ Ø "ˆŒ
Ø!#ˆŒ Ø#%ˆŒ
Ø#$ #ˆÔä

rcóøt|«t|j«rb|jr;|j
s/|j
tj|j««n|j
|j«t|j«r_|jj|jjjdj|j«««g|_ yy)zHandle any buffered data.ÚN)rÚcloserrr/Ú
cdata_elemrrÚunescaper<r=Úappendr5Ú htmlStashÚstoreÚjoinr?s €rrBzHTMLExtractor.close™ø€ä

ŒÜ ˆt|‰|Ô ð×$¨T¯_ª_Ø× Ñ ¤×!4Ñ!4°T·\±\Ó!BÕ× Ñ  §¡Ô ˆt{‰{Ô Ø M‰M× Ñ  §¡×!2Ñ!2×!8Ñ!8¸¿¹ÀÇÁÓ9MÓ!NÔ ˆD rcóhtt|j«dz
|jdz
«D]e}|j|}|jj d|«}|dk(rt|j«}|jj
|dz«Œg|j|jdz
S)zHReturns char index in `self.rawdata` for the start of the current line. éú
r )Úrangerr3ÚlinenorÚfindrE)rÚiiÚlast_line_start_posÚlf_poss rÚ line_offsetzHTMLExtractor.line_offset¨ôœ˜D×4°QÑ¿ ¹ ÀA¹
Ó 5ˆBØ"&×"9Ñ"9¸"Ñ"=Ð Ø—\\×& tÐ-@ÓAˆ˜Š|ä˜TŸ\™\Ó*Ø × *¨6°!©8Õ
×& t§{¡{°1¡}Ñ5rcóÄ|jdk(ry|jdkDry|j|j|j|jzj«dk(S)z†
Returns True if current position is at start of line.
Allows for up to three blank spaces at start of line.
rTr FrA)ÚoffsetrrRÚstrip©rs rÚ
at_line_startzHTMLExtractor.at_line_startµsVð ;‰;˜!Ò ØØ ;‰;˜Š?Øà|‰|˜D×,¨T×-=Ñ-=ÀÇ Á Ñ-KÐL×TÐXZÑZrcóè|j|jz}tjj |j
|«}|r|j
||j
«Sdj|«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</{}>)rRrTrÚ endendtagÚsearchrÚendÚformat)rÚtagrÚms rÚget_endtag_textzHTMLExtractor.get_endtag_textÂs_ð× Ñ  4§;¡;ÑÜ × Ñ × ¯ © °eÓ <ˆÙ Ø—<<  a§e¡e£gÐ —>>  &rcó*||jvr|j||«y|jj|«rJ|js|j «r.|j s"d|_|jjd«|j«}|j r7|jj|«|jj|«y|jj|«||jvr|j«yy)NTrK)r2Úhandle_startendtagr5Úis_block_levelr:rWr9r=rEÚget_starttag_textr;r<ÚCDATA_CONTENT_ELEMENTSÚclear_cdata_mode)rr]ÚattrsÚtexts rÚhandle_starttagzHTMLExtractor.handle_starttagÑà $—/‘/Ñ × # C¨Ô à 7‰7× !  &¨D¯KªK¸D×<NÑ<NÔ<PÐY]×YcÒYcàˆDŒJØ M‰M× Ñ  Ô ×'ˆØ :Š:Ø J‰J× Ñ ˜cÔ K‰K× Ñ ˜tÕ M‰M× Ñ  Ô ×2rcó:|j|«}|jrb|jj|«||jvr7|jr+|jj «|k(rn
|jrŒ+t
|j«dk(rétj|j|j|jzt
|«zd«r|jjd«nd|_ d|_|jj|jjj!dj#|j«««|jjd«g|_yy|jj|«y)NrrKTFrAú
)r_r9r<rEr;ÚpoprÚ
blank_line_reÚmatchrrRrTr:r=r5rFrGrH)rr]rgs rÚ
handle_endtagzHTMLExtractor.handle_endtagæs,Ø×# CÓà :‹:Ø K‰K× Ñ ˜tÔ d—j‘jÑ à—j—zz—~‘~Ó'¨3Òð—j“jô4—::  ×& t§|¡|°D×4DÑ4DÀtÇ{Á{Ñ4RÔUXÐY]ÓU^Ñ4^Ð4_Ð'`Ô—KK×& #'D”Kà"
Ø
×$ T§W¡W×%6Ñ%6×%<Ñ%<¸R¿W¹WÀTÇ[Á[Ó=QÓ%RÔ
×$ VÔ  ð
M‰M× Ñ  Õ &rcó¸|jr d|vrd|_|jr|jj|«y|jj|«y)NrKF)r:r9r<rEr=©rÚdatas rrzHTMLExtractor.handle_datasAØ ;Š;˜4 4™<؈DŒKØ :Š:Ø K‰K× Ñ ˜tÕ M‰M× Ñ  Õ &rcóÖ|js |jr|jj|«y|j «r |rt
j
|j|j|jzt|«zd«r|dz
}nd|_|jr|jdnd}|jd«s,|jd«r|jjd«|jj|jjj|««|jjd«y|jj|«y)z Handle empty tags (`<data>`). NrKTr rArj)r9r:r<rErWrlrmrrRrTrr=Úendswithr5rFrG)rrqÚis_blockÚitems rÚhandle_empty_tagzHTMLExtractor.handle_empty_tag sà :Š:˜Ÿšà K‰K× Ñ ˜tÕ