Ë ø€Wj V ã ó² — d Z ddlZddlZddlmZ dgZ ej d« Z ej d« Z ej d« Z ej d« Z ej d « Z ej d « Z ej d« Z ej d« Z ej d « Z ej d« Z ej dej" « Z ej dej" « Z ej dej" « Z ej d« Z ej d« Z G d„ dej. « Zy)zA parser for HTML and XHTML.é N)ÚunescapeÚ HTMLParserz[&<]z &[a-zA-Z#]z%&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]z)(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]z <[a-zA-Z]z [a-zA-Z]Ú>z--!?>z-?>z0([a-zA-Z][^\t\n\r\f />]*)(?:[\t\n\r\f ]|/(?!>))*a{ ( (?<=['"\t\n\r\f /])[^\t\n\r\f />][^\t\n\r\f /=>]* # attribute name ) ([\t\n\r\f ]*=[\t\n\r\f ]* # value indicator ('[^']*' # LITA-enclosed value |"[^"]*" # LIT-enclosed value |(?!['"])[^>\t\n\r\f ]* # bare value ) )? (?:[\t\n\r\f ]|/(?!>))* # possibly followed by a space 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 (?:[\t\n\r\f ]*=[\t\n\r\f ]* # value indicator (?:'[^']*' # LITA-enclosed value |"[^"]*" # LIT-enclosed value |(?!['"])[^>\t\n\r\f ]* # bare value ) )? [\t\n\r\f /]* # possibly followed by a space )* >? aF <[a-zA-Z][^\t\n\r\f />\x00]* # tag name (?:[\s/]* # optional whitespace before attribute name (?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name (?:\s*=+\s* # value indicator (?:'[^']*' # LITA-enclosed value |"[^"]*" # LIT-enclosed value |(?!['"])[^>\s]* # bare value ) \s* # possibly followed by a space )?(?:\s|/(?!>))* )* )? \s* # trailing whitespace z#\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>c óÜ ‡ — e Zd ZdZdZdZdddœˆ fd„ Zˆ fd„Zd „ Zd „ Z dZ d„ Zdd œd„Zd„ Z d#d„Zd„ Zd„ Zd#d„Zd$d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd „ Zd!„ Zd"„ Z ˆ xZ!S )%r aE Find tags and other markup and call handler functions. Usage: p = HTMLParser() p.feed(data) ... p.close() Start tags are handled by calling self.handle_starttag() or self.handle_startendtag(); end tags by self.handle_endtag(). The data between tags is passed from the parser to the derived class by calling self.handle_data() with the data as argument (the data may be split up in arbitrary chunks). If convert_charrefs is True the character references are converted automatically to the corresponding Unicode character (and self.handle_data() is no longer split in chunks), otherwise they are passed by calling self.handle_entityref() or self.handle_charref() with the string containing respectively the named or numeric reference as the argument. )ÚscriptÚstyleÚxmpÚiframeÚnoembedÚnoframes)ÚtextareaÚtitleTF)Úconvert_charrefsÚ scriptingc ó^ •— t ‰| � « || _ || _ | j « y)az Initialize and reset this instance. If convert_charrefs is true (the default), all character references are automatically converted to the corresponding Unicode characters. If *scripting* is false (the default), the content of the ``noscript`` element is parsed normally; if it's true, it's returned as is without being parsed. N)ÚsuperÚ__init__r r Úreset)Úselfr r Ú __class__s €ú$/usr/lib64/python3.12/html/parser.pyr zHTMLParser.__init__v s( ø€ ô ‰ÑÔØ 0ˆÔØ"ˆŒØ� ‰ �ó c ó¨ •— d| _ d| _ t | _ d| _ d| _ d| _ g | _ d| _ d| _ t ‰| �- « y)z1Reset this instance. Loses all unprocessed data.Ú z???NTr é )ÚrawdataÚlasttagÚinteresting_normalÚinterestingÚ cdata_elemÚ_support_cdataÚ _escapableÚ_pendingÚ_pending_lenÚ_parse_thresholdr r )r r s €r r zHTMLParser.reset… sO ø€ àˆŒØˆŒÜ-ˆÔ؈ŒØ"ˆÔ؈ŒØˆŒ ØˆÔØ !ˆÔÜ ‰‰ �r c ó‚ — | xj t |« z c_ | j | j k r| j j |« y| j s| xj |z c_ nc| j j |« | xj dj | j « z c_ | j j « d| _ t | j « }| j d« t | j « |k rd| _ yt | j « | _ y)z‘Feed data to the parser. Call this as often as you want, with as little or as much text as you want (may include '\n'). r r r N) r$ Úlenr% r# Úappendr ÚjoinÚclearÚgoahead)r ÚdataÚns r ÚfeedzHTMLParser.feed’ sÞ € ð ×ÒœS ›YÑ&ÕØ×јt×4Ñ4Ò4Ø�M‰M× Ñ Õ&à—=’=Ø—’ Ñ$–à— ‘ ×$Ñ$ TÔ*Ø—’ §¡¨¯ © Ó 6Ñ6•Ø— ‘ ×#Ñ#Ô%Ø !ˆDÔÜ�D—L‘LÓ!ˆAØ�L‰L˜ŒOÜ�4—<‘<Ó 1Ò$à()�Õ%ô ),¨D¯L©LÓ(9�Õ%r c óÜ — | j rO| xj dj | j « z c_ | j j « d| _ | j d« y)zHandle any buffered data.r r r N)r# r r) r* r$ r+ ©r s r ÚclosezHTMLParser.close° sG € à�=Š=Ø�LŠL˜BŸG™G D§M¡MÓ2Ñ2�LØ�M‰M×ÑÔ!Ø !ˆDÔØ�‰�Q�r Nc ó — | j S )z)Return full source of start tag: '<...>'.)Ú_HTMLParser__starttag_textr0 s r Úget_starttag_textzHTMLParser.get_starttag_textº s € à×#Ñ#Ð#r ©Ú escapablec óÊ — |j « | _ || _ | j dk( rt j d« | _ y |rT| j sHt j d| j z t j t j z « | _ y t j d| j z t j t j z « | _ y )NÚ plaintextz\Zz&|%s(?=[\t\n\r\f />])z%s(?=[\t\n\r\f />])) Úlowerr r" ÚreÚcompiler r Ú IGNORECASEÚASCII)r Úelemr6 s r Úset_cdata_modezHTMLParser.set_cdata_mode¾ sœ € ØŸ*™*›,ˆŒØ#ˆŒØ�?‰?˜kÒ)Ü!Ÿz™z¨%Ó0ˆDÕÙ ˜t×4Ò4Ü!Ÿz™zÐ*DÀtÇÁÑ*VÜ*,¯-©-¼¿¹Ñ*@ó BˆDÕô "Ÿz™zÐ*BÀTÇ_Á_Ñ*TÜ*,¯-©-¼¿¹Ñ*@ó BˆDÕr c ó6 — t | _ d | _ d| _ y )NT)r r r r" r0 s r Úclear_cdata_modezHTMLParser.clear_cdata_modeÊ s € Ü-ˆÔ؈ŒØˆ�r c ó — || _ y)a Enable or disable support of the CDATA sections. If enabled, "<[CDATA[" starts a CDATA section which ends with "]]>". If disabled, "<[CDATA[" starts a bogus comments which ends with ">". This method is not called by default. Its purpose is to be called in custom handle_starttag() and handle_endtag() methods, with value that depends on the adjusted current node. See https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state for details. N)r! )r Úflags r Ú_set_support_cdatazHTMLParser._set_support_cdataÏ s € ð #ˆÕr c óŽ — | j }d}t |« }||k �r9| j rq| j se|j d|« }|dk r�|j dt ||dz « « }|dk\ r't j d« j ||« s�n¿|}n?| j j ||« }|r|j « }n| j r�n|}||k rJ| j r*| j r| j t ||| « « n| j ||| « | j ||« }||k( r�n|j } |d|« �r=t" j% ||« r| j' |« } n� |d|« r| j) |« } nt |d|« r| j+ |« } nY |d|« r| j- |« } n> |d |« r| j/ |« } n#|d z |k s|r| j d« |d z } n�nH| dk �rl|s�n>t" j% ||« r�nN |d|« rK|dz |k( r| j d« �n*t0 j% ||« r�n| j3 ||dz d « nú |d|« rF|}dD ]' } |j5 | |d z « sŒ|t | « z } n | j3 ||d z | « n« |d|« r$| j6 r| j9 ||dz d « n~|||dz j; « dk( r| j= ||dz d « nM |d |« r| j3 ||dz d « n, |d|« r| j? ||dz d « ntA d« ‚|} | j || « }�n» |d|« r¦tB j% ||« }|rY|jE « dd }| jG |« |jI « } |d| d z « s| d z } | j || « }�Œ÷d||d v r,| j |||dz « | j ||dz « }�n |d|« rütJ j% ||« }|rW|jE d « }| jM |« |jI « } |d| d z « s| d z } | j || « }�Œ¤tN j% ||« }|rE|rB|jE « ||d k( r,|jI « } | |k r|} | j ||d z « }n>|d z |k r'| j d« | j ||d z « }nnJ d« ‚||k r�Œ9|ra||k r\| j r*| j r| j t ||| « « n| j ||| « | j ||« }||d | _ y )Nr Ú<Ú&é" z[\t\n\r\f ;]úú