3 \9@sVdZddlZejdjZejdjZejdZejdZejdZ[Gdd d Z dS) zShared 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@seZdZdZddZddZddZdd Zd d Zd Z d dZ d#ddZ d$ddZ ddZ ddZddZddZddZddZd d!Zd"S)% ParserBaseziParser base class which provides some common support methods used by the SGML/HTML and XHTML parsers.cCs|jtkrtddS)Nz)_markupbase.ParserBase must be subclassed) __class__r RuntimeError)selfr#/usr/lib64/python3.6/_markupbase.py__init__s zParserBase.__init__cCs tddS)Nz.subclasses of ParserBase must override error())NotImplementedError)rmessagerrrerror szParserBase.errorcCsd|_d|_dS)Nr)linenooffset)rrrrreset$szParserBase.resetcCs |j|jfS)z&Return current line number and offset.)r r)rrrrgetpos(szParserBase.getposcCsb||kr |S|j}|jd||}|rN|j||_|jd||}||d|_n|j|||_|S)N r )rawdatacountr rindexr)rijrZnlinesposrrr updatepos0s zParserBase.updateposc Cs|j}|d}|||ddkr*|dS|||ddkrBdSt|}|||ddkrh|j|S||dkr~|j|S|j||\}}|dkr|S|d krd|_x||kr||}|dkr||d|}|d kr|j|n |j||dS|d kr&t||}|sdS|j }n|d krB|j||\} }nt||jkrX|d}n^|dkr|d kr~|j |d|}n$|dkr|j d|n |j dn|j d|||dkr|SqWdS)Nr >-rz--[rZdoctypez"'Z4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZattlistlinktypelinkelementz&unsupported '[' char in %s declarationz"unexpected '[' char in declarationz!unexpected %r char in declaration)rrr">r rr!rr") rlen parse_commentparse_marked_section _scan_name_decl_othercharsZ handle_decl unknown_decl_declstringlit_matchend_parse_doctype_subsetr ) rrrrnZdecltypecdatamnamerrrparse_declaration@sX                 zParserBase.parse_declarationr cCs|j}|j|d|\}}|dkr&|S|d kr@tj||d}n4|dkrZtj||d}n|jd ||d||s|dS|r|jd}|j||d||jdS)Nrtempcdataignoreincludercdataifelseendifz+unknown status keyword %r in marked sectionr >r5r7r4r3r6>r8r9r:r") rr&_markedsectionclosesearch_msmarkedsectioncloser startr(r*)rrreportrZsectNamermatchrrrr%s zParserBase.parse_marked_sectioncCsj|j}|||ddkr$|jdtj||d}|sZhandle_commentr*)rrr?rr@rrrrr$s  zParserBase.parse_commentc Cs4|j}t|}|}x||kr.||}|dkr4|||d}|dkrNdS|dkrt|j||d|jd||d|krdS|d|krdS|||ddkr|j|dd }|dkr|Sq|j|d|\}}|dkrdS|dkr |j||d|jd|t|d|} | ||}|dkr,|Sq|dkr|d|krPdS|j|d|\}}|dkrr|S||dkr,|d}q|dkr|d}x&||kr||jr|d}qW||kr||dkr|S|j|||jdndSq|jr|d}q|j|||jd|qWdS)NrDrEr!rr"r"r")rr#rr r$r&getattrisspace) rr declstartposrr,rr-sr0methrrrr+sn                 z ParserBase._parse_doctype_subsetcCsF|j||\}}|dkrdS|j}d||dkrB|jd|dSdS)Nr rr"r"r")r&rfind)rrrKr0rrrrr_parse_doctype_elementsz!ParserBase._parse_doctype_elementcCs|j}|j||\}}|||d}|dkr2d S|dkrB|dSxv|j||\}}|dkrb|S|||d}|dkr~d S|dkrd||dkr|jd|d}nd Sx |||djr|d}qW||dsd Sn|j||\}}|||d}|s d S|dkrLt||}|r.|j}ndS|||d}|sLdS|dkr||ddkrldS|j|d|\}}|dkr|S|||d}|sdS|dkrF|dSqFWdS)Nr rrr()z'"#r"r"r"r"r"r"r"r"r")rr&rNrJr)r*)rrrKrr0rr-r/rrr_parse_doctype_attlistsZ       z!ParserBase._parse_doctype_attlistcCs|j||\}}|dkr|S|j}xl|||d}|ss