B ƒ f9ã@sVdZddlZe d¡jZe d¡jZe d¡Ze d¡Ze d¡Z[Gdd „d ƒZ dS) zÎShared support for scanning document type declarations in HTML and XHTML. This module is used as a foundation for the html.parser module. It has no documented public API and should not be used directly. éNz[a-zA-Z][-_.a-zA-Z0-9]*\s*z(\'[^\']*\'|"[^"]*")\s*z--\s*>z ]\s*]\s*>z]\s*>c@seZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd Z d d„Z d#dd„Z d$dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"S)%Ú ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.cCs|jtkrtdƒ‚dS)Nz)_markupbase.ParserBase must be subclassed)Ú __class__rÚ RuntimeError)Úself©rú0/opt/alt/python37/lib64/python3.7/_markupbase.pyÚ__init__s zParserBase.__init__cCs tdƒ‚dS)Nz.subclasses of ParserBase must override error())ÚNotImplementedError)rÚmessagerrrÚerror szParserBase.errorcCsd|_d|_dS)Nér)ÚlinenoÚoffset)rrrrÚreset$szParserBase.resetcCs |j|jfS)z&Return current line number and offset.)r r)rrrrÚgetpos(szParserBase.getposcCsb||kr |S|j}| d||¡}|rN|j||_| d||¡}||d|_n|j|||_|S)NÚ r )ÚrawdataÚcountr Úrindexr)rÚiÚjrZnlinesÚposrrrÚ updatepos0s zParserBase.updateposÚc CsÊ|j}|d}|||d…dkr*|dS|||d…dkrBdSt|ƒ}|||d…dkrh| |¡S||dkr~| |¡S| ||¡\}}|dkrš|S|d kr¨d |_x||krÄ||}|dkrþ||d|…}|d krì| |¡n | |¡|dS|d kr&t||ƒ}|sdS|  ¡}n|d krB| ||¡\} }nt||jkrX|d}n^|dkr¤|d kr~|  |d|¡}n$|d kr˜|  d|¡n |  d¡n|  d||¡|dkr¬|Sq¬WdS)Nér ú>)ú-réÿÿÿÿz--ú[rZdoctyperz"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ>ÚattlistÚelementÚlinkÚlinktypez&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration) rÚlenÚ parse_commentÚparse_marked_sectionÚ _scan_nameÚ_decl_othercharsZ handle_declÚ unknown_declÚ_declstringlit_matchÚendÚ_parse_doctype_subsetr ) rrrrÚnZdecltypeÚcÚdataÚmÚnamerrrÚparse_declaration@sX                 zParserBase.parse_declarationr cCsª|j}| |d|¡\}}|dkr&|S|dkr@t ||d¡}n4|dkrZt ||d¡}n| d||d|…¡|s|dS|r | d¡}| ||d|…¡| d¡S)Nér>ÚrcdataÚtempÚincludeÚignoreÚcdata>ÚelseÚifÚendifz+unknown status keyword %r in marked sectionr) rr&Ú_markedsectioncloseÚsearchÚ_msmarkedsectioncloser Ústartr(r*)rrÚreportrZsectNamerÚmatchrrrr%’s zParserBase.parse_marked_sectioncCsj|j}|||d…dkr$| d¡t ||d¡}|sZhandle_commentr*)rrr?rr@rrrrr$¨s  zParserBase.parse_commentc Cs4|j}t|ƒ}|}x||kr.||}|dkr4|||d…}|dkrNdS|dkrt| ||d¡| d|¡|d|kr„dS|d|kr”dS|||d…dkrÄ|j|d d }|d kr|Sq| |d|¡\}}|dkrädS|d kr | ||d¡| d |¡t|d |ƒ} | ||ƒ}|d kr,|Sq|dkrŠ|d|krPdS| |d|¡\}}|d krr|S||dkr,|d}q|dkrþ|d}x&||krÂ|| ¡rÂ|d}qžW||krø||dkrà|S| ||¡| d¡ndSq| ¡r|d}q| ||¡| d|¡qWdS)NúrÚentityÚnotationr z)unknown declaration %r in internal subsetZ_parse_doctype_ú%ú;ú]rz%unexpected char after internal subsetz%unexpected char %r in internal subset)rr#rr r$r&ÚgetattrÚisspace) rrÚ declstartposrr,rr-Úsr0Zmethrrrr+¶sn                 z ParserBase._parse_doctype_subsetcCsF| ||¡\}}|dkrdS|j}d||d…krB| d|¡dSdS)Nrrr )r&rÚfind)rrrKr0rrrrrÚ_parse_doctype_elementùsz!ParserBase._parse_doctype_elementcCsÀ|j}| ||¡\}}|||d…}|dkr2dS|dkrB|dSxv| ||¡\}}|dkrb|S|||d…}|dkr~dS|dkràd||d…kr¨| d|¡d}ndSx |||d… ¡rÌ|d}q®W||d…sðdSn| ||¡\}}|||d…}|s dS|dkrLt||ƒ}|r.| ¡}ndS|||d…}|sLdS|d kr¨||d…d krldS| |d|¡\}}|dkrŽ|S|||d…}|s¨dS|dkrF|dSqFWdS) Nr rrrrú(ú)z'"ú#)rr&rMrJr)r*)rrrKrr0rr-r/rrrÚ_parse_doctype_attlistsZ       z!ParserBase._parse_doctype_attlistcCs”| ||¡\}}|dkr|S|j}xl|||d…}|ss