+
    f0iC                    &   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtH	t	 ]'       d   ^ RI
Ht ]P                  ! R4      t]P                  P                  R4      t]P                  P#                  ]4      t]P&                  P)                  ]4       ]]P*                  R&   ]P                  ! R4      ]n        ]P                  ! R	4      ]n        ]P                  ! R
4      ]n        ]P                  ! R4      ]n        ]P2                  ]n        ]P                  ! R]P6                  4      ]n        ]P                  ! R]P6                  4      ]n        ]P                  ! R4      t ! R R]P>                  4      t ] ]n         ! R R]P>                  4      t!R# )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                  >   a  ] tR t^`tRtV 3R ltR V 3R lltRtV ;t# )_HTMLParserz"Handle special start and end tags.c                	.  < V P                   W^,            p\        VR,          4      p\        V4      ^8  g#   ^ATu;8:  d   ^Z8:  gA   M ^aTu;8:  d   ^z8:  g0   M V P                  V P                   W^,            4       V^,           # \        SV `  V4      # )   )rawdataordlenhandle_datasuperparse_endtag)selfistartc	__class__s   &&  Y/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/markdown/htmlparser.pyr   _HTMLParser.parse_endtagc   su    Qs#b	Nu:>"-R-2>c>T\\!E23q5Lw#A&&    c                    V ^8  d   QhRRRR/#    r   intreturn )formats   "r   __annotate___HTMLParser.__annotate__k   s     ) ) ) )r   c                	   < V P                   W^,            R8X  d.   V P                  V P                   W^,            4       V^,           # \        SV `  V4      # )r
   </>)r   r   r   parse_starttagr   r   r   s   &&r   r%   _HTMLParser.parse_starttagk   sL    <<a% E)T\\!E23q5Lw%a((r   r   )	__name__
__module____qualname____firstlineno____doc__r   r%   __static_attributes____classcell__r   s   @r   r   r   `   s    ,') )r   r   c                  h  a  ] tR t^xt$ RtR V 3R lltV 3R ltV 3R lt]R R l4       t	R R	 lt
R
 R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" V 3R# lltR1R$ ltR% V 3R& lltR2R' V 3R( llltR)tR*]R+&   R, R- ltR. R/ ltR0tV ;t # )3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                   V ^8  d   QhRR/# )r   mdr   r   )r    s   "r   r!   HTMLExtractor.__annotate__   s      8 r   c                	~   < R V9  d   RVR &   \        R.4      V n        ^ .V n        \        SV `  ! V/ VB  Wn        R# )convert_charrefsFhrN)set
empty_tagslineno_start_cacher   __init__r3   )r   r3   argskwargsr   s   &&*,r   r;   HTMLExtractor.__init__   sH    V+).F%& tf+#$# 	$)&)r   c                z   < RV n         RV n        . V n        . V n        . V n        ^ .V n        \        SV `  4        R# )z1Reset this instance.  Loses all unprocessed data.FN)inrawintailstack_cachecleandocr:   r   resetr   r   s   &r   rE   HTMLExtractor.reset   s9    
 "
!##%#$#r   c                ,  < \         SV `  4        \        V P                  4      '       do   V P                  '       dB   V P
                  '       g0   V P                  \        P                  V P                  4      4       MV P                  V P                  4       \        V P                  4      '       da   V P                  P                  V P                  P                  P                  RP                  V P                  4      4      4       . V n	        R# R# )zHandle any buffered data. N)r   closer   r   r6   
cdata_elemr   r   unescaperC   rD   appendr3   	htmlStashstorejoinrF   s   &r   rJ   HTMLExtractor.close   s    t|| $$$T___  !4!4T\\!BC  .t{{MM  !2!2!8!89M!NODK r   c                   V ^8  d   QhRR/# )r   r   r   r   )r    s   "r   r!   r4      s     
6 
6S 
6r   c                   \        \        V P                  4      ^,
          V P                  ^,
          4       Fp  pV P                  V,          pV P                  P                  RV4      pVR8X  d   \        V P                  4      pV P                  P                  V^,           4       Kr  	  V P                  V P                  ^,
          ,          # )zHReturns char index in `self.rawdata` for the start of the current line. 
r   )ranger   r:   linenor   findrM   )r   iilast_line_start_poslf_poss   &   r   line_offsetHTMLExtractor.line_offset   s     D334Q6AFB"&"9"9""=\\&&t-@AF|T\\*##**6!84 G &&t{{1}55r   c                   V ^8  d   QhRR/# )r   r   boolr   )r    s   "r   r!   r4      s     [ [t [r   c                    V P                   ^ 8X  d   R# V P                   ^8  d   R# V P                  V P                  V P                  V P                   ,            P                  4       R8H  # )zn
Returns True if current position is at start of line.

Allows for up to three blank spaces at start of line.
TFrI   )offsetr   r[   stripr   s   &r   at_line_startHTMLExtractor.at_line_start   sV     ;;!;;?||D,,T-=-=-KLRRTXZZZr   c                    V ^8  d   QhRRRR/# )r   tagstrr   r   )r    s   "r   r!   r4      s     ' '3 '3 'r   c                    V P                   V P                  ,           p\        P                  P	                  V P
                  V4      pV'       d   V P
                  W#P                  4        # RP                  V4      # )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</{}>)r[   r`   r   	endendtagsearchr   endr    )r   rf   r   ms   &&  r   get_endtag_textHTMLExtractor.get_endtag_text   s]       4;;.  ''e<<<eeg.. >>#&&r   c                    V ^8  d   QhRRRR/# )r   rf   rg   attrszSequence[tuple[str, str]]r   )r    s   "r   r!   r4      s     ( (3 (/H (r   c                	t   WP                   9   d   V P                  W4       R # V P                  P                  V4      '       d]   V P                  '       g)   V P                  4       '       d5   V P                  '       g#   RV n        V P                  P                  R4       V P                  4       pV P                  '       d9   V P                  P                  V4       V P                  P                  V4       R # V P                  P                  V4       WP                  9   d   V P                  4        R # R # )NTrT   )r9   handle_startendtagr3   is_block_levelrA   rc   r@   rD   rM   get_starttag_textrB   rC   CDATA_CONTENT_ELEMENTSclear_cdata_mode)r   rf   rp   texts   &&& r   handle_starttagHTMLExtractor.handle_starttag   s    //!##C/77!!#&&DKKKD<N<N<P<PY]YcYcYcDJMM  &%%':::JJc"KKt$MM  &111%%' 2r   c                   V ^8  d   QhRR/# r   rf   rg   r   )r    s   "r   r!   r4      s     ' ' 'r   c                	j   V P                  V4      pV P                  '       Edt   V P                  P                  V4       WP                  9   d5   V P                  '       d#   V P                  P                  4       V8X  g   K3   \        V P                  4      ^ 8X  d   \        P                  V P                  V P                  V P                  ,           \        V4      ,           R 4      '       d   V P                  P                  R4       MRV n        RV n        V P                  P                  V P                  P                  P!                  RP#                  V P                  4      4      4       V P                  P                  R4       . V n        R# R# V P                  P                  V4       R# )    NrT   TFrI   

)rm   r@   rC   rM   rB   popr   blank_line_rematchr   r[   r`   rA   rD   r3   rN   rO   rP   )r   rf   rw   s   && r   handle_endtagHTMLExtractor.handle_endtag   s&   ##C(:::KKt$jj jjjzz~~'3.4::!# &&t||D4D4Dt{{4RUXY]U^4^4_'`aaKK&&t, #'DK"
$$TWW%6%6%<%<RWWT[[=Q%RS$$V,  $ MM  &r   c                   V ^8  d   QhRR/# r   datarg   r   )r    s   "r   r!   r4     s     ' ' 'r   c                	    V P                   '       d   R V9   d   RV n         V P                  '       d   V P                  P                  V4       R# V P                  P                  V4       R# )rT   FN)rA   r@   rC   rM   rD   r   r   s   &&r   r   HTMLExtractor.handle_data  sE    ;;;44<DK:::KKt$MM  &r   c                    V ^8  d   QhRRRR/# )r   r   rg   is_blockr^   r   )r    s   "r   r!   r4   	  s     ' 'S 'D 'r   c                \   V P                   '       g   V P                  '       d   V P                  P                  V4       R# V P	                  4       '       Ed9   V'       Ed0   \
        P                  V P                  V P                  V P                  ,           \        V4      ,           R 4      '       d   VR,          pMRV n        V P                  '       d   V P                  R,          MRpVP                  R4      '       g3   VP                  R4      '       d   V P                  P                  R4       V P                  P                  V P                  P                  P                  V4      4       V P                  P                  R4       R# V P                  P                  V4       R# )zHandle empty tags (`<data>`). NrT   TrI   r~   r   )r@   rA   rC   rM   rc   r   r   r   r[   r`   r   rD   endswithr3   rN   rO   )r   r   r   items   &&& r   handle_empty_tagHTMLExtractor.handle_empty_tag	  s   :::KKt$!!hh""4<<0@0@4;;0NQTUYQZ0Z0[#\]] #(,4==$2D==((T]]4-@-@$$T*MM  !2!2!8!8!>?MM  (MM  &r   c                   V ^8  d   QhRR/# r{   r   )r    s   "r   r!   r4      s     ^ ^c ^r   c                	z    V P                  V P                  4       V P                  P                  V4      R 7       R# )r   N)r   rt   r3   rs   )r   rf   rp   s   &&&r   rr    HTMLExtractor.handle_startendtag   s.    d446AWAWX[A\]r   c                   V ^8  d   QhRR/# r   namerg   r   )r    s   "r   r!   r4   #  s     D D3 Dr   c                	J    V P                  R P                  V4      RR7       R# )z&#{};Fr   Nr   r    r   r   s   &&r   handle_charrefHTMLExtractor.handle_charref#  s    gnnT2UCr   c                   V ^8  d   QhRR/# r   r   )r    s   "r   r!   r4   &  s     C CS Cr   c                	J    V P                  R P                  V4      RR7       R# )z&{};Fr   Nr   r   s   &&r   handle_entityrefHTMLExtractor.handle_entityref&  s    fmmD1EBr   c                   V ^8  d   QhRR/# r   r   )r    s   "r   r!   r4   )  s     G G3 Gr   c                	J    V P                  R P                  V4      RR7       R# )z	<!--{}-->Tr   Nr   r   s   &&r   handle_commentHTMLExtractor.handle_comment)  s     k006Fr   c                   V ^8  d   QhRR/# r   r   )r    s   "r   r!   r4   -  s     C C Cr   c                	J    V P                  R P                  V4      RR7       R# )z<!{}>Tr   Nr   r   s   &&r   handle_declHTMLExtractor.handle_decl-  s    gnnT2TBr   c                   V ^8  d   QhRR/# r   r   )r    s   "r   r!   r4   0  s     D Dc Dr   c                	J    V P                  R P                  V4      RR7       R# )z<?{}?>Tr   Nr   r   s   &&r   	handle_piHTMLExtractor.handle_pi0  s    hood3dCr   c                   V ^8  d   QhRR/# r   r   )r    s   "r   r!   r4   3  s     J J Jr   c                	    VP                  R 4      '       d   RMRpV P                  RP                  W4      RR7       R# )zCDATA[z]]>z]>z<![{}{}Tr   N)
startswithr   r    )r   r   rk   s   && r   unknown_declHTMLExtractor.unknown_decl3  s5    x00edi..t9DIr   c                    V ^8  d   QhRRRR/# r   r   )r    s   "r   r!   r4   7  s      # # r   c                	   < V P                  4       '       g   V P                  '       d   \        SV `  V4      # V P	                  R 4       V^,           # )z<?)rc   rA   r   parse_pir   r&   s   &&r   r   HTMLExtractor.parse_pi7  sC    4;;;7#A&& 	1ur   c                	X   V P                   pVP                  R V4      '       g   Q R4       h\        P                  W1^,           4      pV'       g   V P	                  R4       V^,           # V'       d+   VP                  4       pV P                  W1^,           V 4       VP                  4       # )z<!--z"unexpected call to parse_comment()<)r   r   commentcloserj   r   r   r   rk   )r   r   reportr   r   js   &&&   r   parse_commentHTMLExtractor.parse_commentA  s    ,,!!&!,,R.RR,##GqS1S!q5LA!Q0yy{r   c                    V ^8  d   QhRRRR/# r   r   )r    s   "r   r!   r4   M  s        r   c                	  < V P                  4       '       g   V P                  '       d   V P                  W^,            R8X  db   V P                  W^	,            R8X  gH   V P                  V4      pVR8X  d.   V P	                  V P                  W^,            4       V^,           # V# \
        SV `  V4      # V P	                  R4       V^,           # )r
   z<![z	<![CDATA[z<!r   )rc   rA   r   parse_bogus_commentr   r   parse_html_declaration)r   r   resultr   s   && r   r   $HTMLExtractor.parse_html_declarationM  s    4;;;||Ac"e+DLLQ34G;4V 11!4R<$$T\\!E%:;q5L71!44 	1ur   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   )r    s   "r   r!   r4   ]  s!      S # c r   c                	v   < \         SV `  W4      pVR8X  d   R# V P                  V P                  W RR7       V# )   Fr   r   )r   r   r   r   )r   r   r   posr   s   &&& r   r   !HTMLExtractor.parse_bogus_comment]  sA     g)!4"9Idll11EB
r   Nz
str | None_HTMLExtractor__starttag_textc                   V ^8  d   QhRR/# )r   r   rg   r   )r    s   "r   r!   r4   l  s     $ $3 $r   c                    V P                   # )z)Return full source of start tag: `<...>`.)r   rb   s   &r   rt   HTMLExtractor.get_starttag_textl  s    ###r   c                    V ^8  d   QhRRRR/# r   r   )r    s   "r   r!   r4   p  s     6 6 6 6r   c                	&   V P                   W^,            R8X  d.   V P                  V P                   W^,            4       V^,           # RV n        V P                  V4      pV^ 8  d.   V P                  V P                   W^,            4       V^,           # V P                   pW1V V n        . p\        P
                  P                  W1^,           4      pV'       g   Q R4       hVP                  4       pVP                  ^4      P                  4       ;V n
        pWb8  d   \        P                  P                  W64      pV'       g   MVP                  ^^^4      w  rpV
'       g   RpM<VR,          Ru;8X  d   VR	R 8X  g   M VR,          Ru;8X  d   VR	R 8X  d	   M MV^R	 pV'       d   \        P                  V4      pVP                  V	P                  4       V34       VP                  4       pK  W6V P                  4       pVR
9  d   V P                  4       w  rRV P                  9   dX   WP                  P!                  R4      ,           p\#        V P                  4      V P                  P%                  R4      ,
          pMV\#        V P                  4      ,           pV P                  W1V 4       V# VP'                  R4      '       d   V P)                  Wt4       V# WpP*                  9   d   V P-                  V4       V P/                  Wt4       V# )r
   r$   Nz#unexpected call to parse_starttag():Nr   N'"/>rT   r   )>r   )r   r   r   check_for_whole_start_tagr   tagfind_tolerantr   rk   grouplowerlasttagattrfind_tolerantrL   rM   ra   getposcountr   rfindr   rr   ru   set_cdata_moderx   )r   r   endposr   rp   r   krf   rl   attrnamerest	attrvaluerk   rV   r`   s   &&             r   r%   HTMLExtractor.parse_starttagp  s   <<a% E)T\\!E23q5L#//2A:T\\!E23q5L,,&0 ++11'Q3?;;;uIIK"[[^1133sj,,227>A()1a(8%HI 	2$8)BC.82#7237%aO	&//	:	LL(..*I67A%%'k!![[]NFt+++"6"6"<"<T"BBT112//55d;<  #d&:&:";;Wv./M<<##C/  111##C(  ,r   )
__starttag_textrC   rD   r9   r@   rA   r   r:   r3   rB   )T)r}   )!r(   r)   r*   r+   r,   r;   rE   rJ   propertyr[   rc   rm   rx   r   r   r   rr   r   r   r   r   r   r   r   r   r   r   r   __annotations__rt   r%   r-   r.   r/   s   @r   r1   r1   x   s     	 
6 
6['(*'6''.^DCGCDJ 
    #'OZ&$6 6r   r1   )"r,   
__future__r   reimportlib.util	importlibsystypingr   r   markdownr   compiler   util	find_specspecmodule_from_specr   loaderexec_modulemodulesstarttagopen
endtagopenpiclose	entityref
incompleteVERBOSElocatestarttagend_tolerantlocatetagendr   
HTMLParserr   r1   r   r   r   <module>r      sT  ( # 	  
 *! zz(# ~~.^^,,T2
   
 #&L  **_5
 

=1
  ZZ'
 zz"?@
  #,,
 (*

 4 ZZ)
 % ** & ZZ
 " 

?+)*'' )* $
 nJ)) nr   