a
    W_h                     @   sl  d Z ddlZddlmZmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlmZm Z  g d	Z!G d
d de
Z"G dd de
Z#G dd de
Z$G dd de
Z%G dd de
Z&G dd de
Z'G dd de'Z(G dd deZ)G dd deZ*G dd deZ+G dd de
Z,G d d! d!e
Z-dS )"z
    pygments.lexers.markup
    ~~~~~~~~~~~~~~~~~~~~~~

    Lexers for non-HTML markup languages.

    :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    N)	HtmlLexerXmlLexer)JavascriptLexer)CssLexer)	
RegexLexerDelegatingLexerincludebygroupsusingthisdo_insertionsdefaultwords)
TextCommentOperatorKeywordNameStringNumberPunctuationGenericOther)get_bool_optClassNotFound)BBCodeLexerMoinWikiLexerRstLexerTexLexer
GroffLexerMozPreprocHashLexerMozPreprocPercentLexerMozPreprocXulLexerMozPreprocJavascriptLexerMozPreprocCssLexerMarkdownLexerTiddlyWiki5Lexerc                   @   sh   e Zd ZdZdZdgZdgZdefdedfdefgd	efd
e	e
jeefde	eefdedfgdZdS )r   zR
    A lexer that highlights BBCode(-like) syntax.

    .. versionadded:: 0.6
    ZBBCodeZbbcodeztext/x-bbcodez[^[]+z\[/?\w+tagz\[\s+z(\w+)(=)("?[^\s"\]]+"?)z(=)("?[^\s"\]]+"?)z\]#pop)rootr'   N)__name__
__module____qualname____doc__namealiases	mimetypesr   r   r	   r   	Attributer   r   tokens r4   r4   8/usr/lib/python3/dist-packages/pygments/lexers/markup.pyr      s$   r   c                   @   s   e Zd ZdZdZddgZg ZdgZej	ej
B Zdefdeeefdeejeeejefd	eejejd
fdefdeeejefdeeejefdefdeeeefdefdefdefdefgdejdfdedfdejfdejfgdZdS )r   zI
    For MoinMoin (and Trac) Wiki markup.

    .. versionadded:: 0.7
    zMoinMoin/Trac Wiki markupz	trac-wikiZmoinztext/x-trac-wikiz^#.*$z(!)(\S+)z^(=+)([^=]+)(=+)(\s*#.+)?$z(\{\{\{)(\n#!.+)?	codeblockz(\'\'\'?|\|\||`|__|~~|\^|,,|::)z^( +)([.*-])( )z^( +)([a-z]{1,5}\.)( )z\[\[\w+.*?\]\]z(\[[^\s\]]+)(\s+[^\]]+?)?(\])z^----+$z[^\n\'\[{!_~^,|]+\n.z\}\}\}r)   z\{\{\{z#pushz[^{}]+)r*   r6   N)r+   r,   r-   r.   r/   r0   	filenamesr1   re	MULTILINE
IGNORECASEflagsr   r	   r   r   r   Headingr
   r   r   r   BuiltinZ	NamespacePreprocr3   r4   r4   r4   r5   r   ?   s<   

r   c                   @   sz  e Zd ZdZdZg dZddgZddgZej	Z
dd	 Zd
ZdZdeeeef Zdeejeejeejefdeejeejefdeeeeeddfdeeeeeddfdeeeeeddfdeeeeeddfdeeeeeddfdeeeeeddfdefdeeeejeeeeddfdeeeejeeddfdeeeejeeddfdeeeejeejeeeeddfdejfdeeejefdeeeddeeddfdeej eeeeefe!dgd efd!ed"fd#eeej"efd$efd%eej#ej$fd&eej$ej#fd'ej%fd(ej&fd)efd*ejfd+efd,efgd-efd!e ed.fd/efgd0Z'd1d2 Z(d3d4 Z)d5S )6r   a  
    For `reStructuredText <http://docutils.sf.net/rst.html>`_ markup.

    .. versionadded:: 0.7

    Additional options accepted:

    `handlecodeblocks`
        Highlight the contents of ``.. sourcecode:: language``,
        ``.. code:: language`` and ``.. code-block:: language``
        directives with a lexer for the given language (default:
        ``True``).

        .. versionadded:: 0.8
    ZreStructuredText)ZrstrestZrestructuredtextz*.rstz*.restz
text/x-rstztext/prs.fallenstein.rstc           
   	   c   s  ddl m} |dt|dfV  |dt|dfV  |dtj|dfV  |dt|dfV  |dt|dfV  |dt|dfV  |d	t|d	fV  d }| j	rz||d
 }W n ty   Y n0 |d
}t|}||d |d |d }|d u r>|d
t|fV  d S g }|d}d}|D ]P}	t|	|kr|t|dt|	d | fgf ||	|d  7 }n||	7 }qTt|||E d H  d S )Nr   get_lexer_by_name                        	   
      T )pygments.lexersrC   startr   groupr   r   Wordr   handlecodeblocksstripr   lenr   
splitlinesappendr   get_tokens_unprocessed)
selfmatchrC   lexerZ	indentionZindention_sizecodeZinsZ	codelinesliner4   r4   r5   _handle_sourcecode   s:    
"

"zRstLexer._handle_sourcecodeu   '")]}>’”»!?u   ‐‑‒–— z((?=$)|(?=[-/:.,; \n\x00%s%s]))zH^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)(.+)(\n)(\1)(\n)zc^(\S.*)(\n)(={3,}|-{3,}|`{3,}|:{3,}|\.{3,}|\'{3,}|"{3,}|~{3,}|\^{3,}|_{3,}|\*{3,}|\+{3,}|#{3,})(\n)z!^(\s*)([-*+])( .+\n(?:\1  .+\n)*)inlinestatez1^(\s*)([0-9#ivxlcmIVXLCM]+\.)( .+\n(?:\1  .+\n)*)z4^(\s*)(\(?[0-9#ivxlcmIVXLCM]+\))( .+\n(?:\1  .+\n)*)z$^(\s*)([A-Z]+\.)( .+\n(?:\1  .+\n)+)z*^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1  .+\n)+)z^(\s*)(\|)( .+\n(?:\|  .+\n)*)zl^( *\.\.)(\s*)((?:source)?code(?:-block)?)(::)([ \t]*)([^\n]+)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*)?\n)+)z,^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))z'^( *\.\.)(\s*)(_(?:[^:\\]|\\.)+:)(.*?)$z^( *\.\.)(\s*)(\[.+\])(.*?)$z9^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))z^ *\.\..*(\n( +.*\n|\n)+)?z+^( *)(:(?:\\\\|\\:|[^:\n])+:(?=\s))([ \t]*)z!^(\S.*(?<!::)\n)((?:(?: +.*)\n)+)z2(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*)?\n)+)\\.z``literalz(`.+?)(<.+?>)(`__?)z`.+?`__?z(`.+?`)(:[a-zA-Z0-9:-]+?:)?z(:[a-zA-Z0-9:-]+?:)(`.+?`)z\*\*.+?\*\*z\*.+?\*z\[.*?\]_z<.+?>z[^\\\n\[*`:]+r8   z[^`]+r)   `)r*   r`   rd   c                 K   s$   t |dd| _tj| fi | d S NrT   Tr   rT   r   __init__rZ   Zoptionsr4   r4   r5   rh     s    zRstLexer.__init__c                 C   s   | d d dkr$| dd dkr$dS |  d}|  d|d }|dkr|d d |kr| |d  d	v r| |d  | |d  krd
S d S )NrE   z..rF   r8   g333333?
rD   z-=g      ?)find)textZp1Zp2r4   r4   r5   analyse_text  s     
zRstLexer.analyse_textN)*r+   r,   r-   r.   r/   r0   r9   r1   r:   r;   r=   r_   ZclosersZunicode_delimitersescapeZend_string_suffixr	   r   r>   r   r   r
   r   r   r   rS   r   Tagr   r@   Classr   Escaper   ZInterpolVariabler2   StrongEmphr3   rh   rn   r4   r4   r4   r5   r   l   s   )
:Rr   c                
   @   s  e Zd ZdZdZddgZg dZddgZdefd	e	j
fd
e	j
fgdejdfdedfdejdfdedfdedfdefeddefgde	jfeddefdefde	j
fgdedfdedfedgdedfdedfde	j
fedgde	jfdefedgdZd d! Zd"S )#r   z<
    Lexer for the TeX and LaTeX typesetting languages.
    ZTeXZtexZlatex)z*.texz*.auxz*.tocz
text/x-texztext/x-latexz%.*?\nz[{}]z[&_^]z\\\[displaymathz\\\(
inlinemathz\$\$z\$z\\([a-zA-Z]+|.)commandz\\$generalz[^\\$%&_^{}]+[0-9]+z[-=!+*/()\[\]]z[^=!+*/()\[\]\\$%&_^{}0-9-]+z\\\)r)   mathz\\\]z\[.*?\]z\*)ry   r*   r{   rw   rv   rx   c                 C   s(   dD ]}| d t | |kr dS qd S )N)z\documentclassz\inputz\documentstylez\relaxT)rV   )rm   rQ   r4   r4   r5   rn   F  s    zTexLexer.analyse_textN)r+   r,   r-   r.   r/   r0   r9   r1   r   r   r?   r   Backtickr   r   r   rs   r   r   r2   r   r3   rn   r4   r4   r4   r5   r     sN   

)r   c                
   @   s   e Zd ZdZdZg dZddgZddgZdee	e
d	fd
ed	fde	dfedgedde	fde	dfgdefdejfdejfdejfdejfde	d	fgde	dfeddejfdefdefde	fgdZdd ZdS )r   z
    Lexer for the (g)roff typesetting language, supporting groff
    extensions. Mainly useful for highlighting manpage sources.

    .. versionadded:: 0.6
    ZGroff)ZgroffZnroffZmanz*.[1234567]z*.manzapplication/x-troffz
text/troffz	(\.)(\w+)requestz\.z[^\\\n]+textlineescapesr7   r)   z	\\"[^\n]*z\\[fn]\wz\\\(.{2}z	\\.\[.*\]rc   z\\\nz	"[^\n"]+"z\d+z\S+r(   )r*   r~   r   r}   c                 C   s`   | d d dkrdS | d d dkr(dS | d d dkr<dS | dd   r\| d  r\d	S d S )
NrD   r8   FrF   z.\"TrG   z.TH g?)isalnumisspace)rm   r4   r4   r5   rn   z  s    zGroffLexer.analyse_textN)r+   r,   r-   r.   r/   r0   r9   r1   r	   r   r   r   r   r   r   r   rr   Doubler   r3   rn   r4   r4   r4   r5   r   M  s<   
 r   c                   @   s   e Zd ZdZdZegZg Zg Zdej	dfde
fgdeej	edfedej	d	fged
efdeeefdefdejfdejfdejfdefded	fdefdefg
dZdS )r    z
    Lexer for Mozilla Preprocessor files (with '#' as the marker).

    Other data is left untouched.

    .. versionadded:: 2.0
    Zmozhashpreprocz^#expr	exprstart.+z(literal)(.*)z#pop:2)ZdefineZundefifZifdefZifndefelseelifZelifdefZelifndefZendifexpandfilterZunfilterr   Zincludesubsterrorr)   )!z!=z==z&&z||z(defined)(\()z\)rz   z__\w+?__z@\w+?@z\w+r7   r(   z\S)r*   r   r   N)r+   r,   r-   r.   r/   r0   r9   r1   r   r@   r   r	   r   r   r   r   r   r   ZDecimalr   rs   rq   r3   r4   r4   r4   r5   r      s2   
	
r    c                   @   s:   e Zd ZdZdZegZg Zg Zddej	dfde
fgiZdS )r!   z
    Lexer for Mozilla Preprocessor files (with '%' as the marker).

    Other data is left untouched.

    .. versionadded:: 2.0
    Zmozpercentpreprocr*   z^%r   r   N)r+   r,   r-   r.   r/   r0   r9   r1   r   r@   r   r3   r4   r4   r4   r5   r!     s   
r!   c                       s4   e Zd ZdZdZdgZdgZg Z fddZ  Z	S )r"   z
    Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
    `XmlLexer`.

    .. versionadded:: 2.0
    zXUL+mozpreproczxul+mozpreprocz*.xul.inc                    s   t  jttfi | d S N)superrh   r   r    ri   	__class__r4   r5   rh     s    zMozPreprocXulLexer.__init__
r+   r,   r-   r.   r/   r0   r9   r1   rh   __classcell__r4   r4   r   r5   r"     s   r"   c                       s4   e Zd ZdZdZdgZdgZg Z fddZ  Z	S )r#   z
    Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
    `JavascriptLexer`.

    .. versionadded:: 2.0
    zJavascript+mozpreproczjavascript+mozpreprocz*.js.inc                    s   t  jttfi | d S r   )r   rh   r   r    ri   r   r4   r5   rh     s    z"MozPreprocJavascriptLexer.__init__r   r4   r4   r   r5   r#     s   r#   c                       s4   e Zd ZdZdZdgZdgZg Z fddZ  Z	S )r$   z
    Subclass of the `MozPreprocHashLexer` that highlights unlexed data with the
    `CssLexer`.

    .. versionadded:: 2.0
    zCSS+mozpreproczcss+mozpreprocz*.css.inc                    s   t  jttfi | d S r   )r   rh   r   r!   ri   r   r4   r5   rh     s    zMozPreprocCssLexer.__init__r   r4   r4   r   r5   r$     s   r$   c                   @   s  e Zd ZdZdZdgZddgZdgZej	Z
dd Zd	eejefd
eejefdeejeejefdeejeejefdeeeeeeddfdeeeeeeddfdeeeeeddfdeeejfdejfdefdeeejfedgdefdeeejfdeejfdeejfdeejfdeejfdeeejfdejfdeeejeeejefdeeejeeejefd eeejeejfd!efd"efgd#Zd$d% Z d&S )'r%   zt
    For `Markdown <https://help.github.com/categories/writing-on-github/>`_ markup.

    .. versionadded:: 2.2
    ZmarkdownZmdz*.mdz
*.markdownztext/x-markdownc                 c   s   ddl m} |dtj|dfV  |dtj|dfV  |dt|dfV  d}| jrz||d }W n t	y   Y n0 |d}|du r|dt|fV  nt
g ||E dH  |dtj|dfV  dS 	zV
        match args: 1:backticks, 2:lang_name, 3:newline, 4:code, 5:backticks
        r   rB   rD   rE   rF   NrG   rH   )rP   rC   rQ   r   r|   rR   r   rT   rU   r   r   rY   rZ   r[   rC   r\   r]   r4   r4   r5   _handle_codeblock  s    
zMarkdownLexer._handle_codeblockz(^#[^#].+)(\n)z(^#{2,6}[^#].+)(\n)z^(.+)(\n)(=+)(\n)z^(.+)(\n)(-+)(\n)z^(\s*)([*-] )(\[[ xX]\])( .+\n)r`   ra   z^(\s*)([*-])(\s)(.+\n)z^(\s*)([0-9]+\.)( .+\n)z^(\s*>\s)(.+\n)z^(\s*```\n(.+\n)+\s*```$)z&^(\s*```)(\w+)(\n)([\w\W]*?)(^\s*```$)z(\n\n)((\ {4}|\t)(.+\n)+)rc   z([^`])(`[^`\n]+`)z(\*\*[^* \n][^*\n]*\*\*)z(\_\_[^_ \n][^_\n]*\_\_)z(\*[^* \n][^*\n]*\*)z(\_[^_ \n][^_\n]*\_)z([^~]*)(~~[^~]+~~)z[@#][\w/:]+z (!?\[)([^]]+)(\])(\()([^)]+)(\))z(\[)([^]]+)(\])(\[)([^]]*)(\])z^(\s*\[)([^]]*)(\]:\s*)(.+)z[^\\\s]+r8   )r*   r`   c                 K   s$   t |dd| _tj| fi | d S rf   rg   ri   r4   r4   r5   rh   ]  s    zMarkdownLexer.__init__N)!r+   r,   r-   r.   r/   r0   r9   r1   r:   r;   r=   r   r	   r   r>   r   
Subheadingr   r
   r   ru   r   r|   r   rt   Deletedr   ZEntityrp   r2   ZLabelr3   rh   r4   r4   r4   r5   r%     s`   Br%   c                   @   s  e Zd ZdZdZdgZdgZdgZej	Z
dd Zdd	 Zd
eeeejfdeejefdeejefdeeeeeeddfdeeeefdeejfdeejfdeejfdeejfdeeeefdefdefededgeddddefgdefdejfdeeejefd eeejfd!eeejfd"eeejfd#eeejefd$eeejefd%ejfd&ejfd'ejfd(ejfd)ejfd*ejfd+ej fd,eeejefd-eeejeej!efd.eeejefd/eej!fd0efd1efgd2Z"d3d4 Z#d5S )6r&   zf
    For `TiddlyWiki5 <https://tiddlywiki.com/#TiddlerFiles>`_ markup.

    .. versionadded:: 2.7
    Ztiddlertidz*.tidztext/vnd.tiddlywikic                 c   s   ddl m} |dt|dfV  |dt|dfV  |dt|dfV  d}| jrz||d }W n ty   Y n0 |d}|du r|dt|fV  dS t	g |
|E dH  |dt|dfV  dS r   )rP   rC   rQ   r   rR   r   rT   rU   r   r   rY   r   r4   r4   r5   r   n  s     
z"TiddlyWiki5Lexer._handle_codeblockc                 c   s   ddl m} |dt|dfV  |dt|dfV  d}| jrfz|d}W n tyd   Y n0 |d}|du r|dt|fV  dS tg ||E dH  |dt|dfV  dS )	zP
        match args: 1:style tag 2:newline, 3:code, 4:closing style tag
        r   rB   rD   rE   NZcssrF   rG   )	rP   rC   rQ   r   rR   rT   r   r   rY   r   r4   r4   r5   _handle_cssblock  s    
z!TiddlyWiki5Lexer._handle_cssblockz^(title)(:\s)(.+\n)z^(!)([^!].+\n)z^(!{2,6})(.+\n)z^(\s*)([*#>]+)(\s*)(.+\n)r`   ra   z^(<<<.*\n)([\w\W]*?)(^<<<.*$)z^(\|.*?\|h)$z^(\|.*?\|[cf])$z^(\|.*?\|k)$z^(;.*)$z^(```\n)([\w\W]*?)(^```$)z ^(```)(\w+)(\n)([\w\W]*?)(^```$)z$^(<style>)(\n)([\w\W]*?)(^</style>$)keywords)z\definez\endZcaptionZcreatedZmodifiedZtagstitletype^z\b)prefixsuffixrc   z\d{17}z(\s)(//[^/]+//)((?=\W|\n))z(\s)(\^\^[^\^]+\^\^)z(\s)(,,[^,]+,,)z(\s)(__[^_]+__)z(\s)(''[^']+'')((?=\W|\n))z(\s)(~~[^~]+~~)((?=\W|\n))z	<<[^>]+>>z\$\$[^$]+\$\$z\$\([^)]+\)\$z^@@.*$z	</?[^>]+>z`[^`]+`z&\S*?;z(\[{2})([^]\|]+)(\]{2})z$(\[{2})([^]\|]+)(\|)([^]\|]+)(\]{2})z(\{{2})([^}]+)(\}{2})z(\b.?.?tps?://[^\s"]+)z[\w]+r8   )r*   r   r`   c                 K   s$   t |dd| _tj| fi | d S rf   rg   ri   r4   r4   r5   rh     s    zTiddlyWiki5Lexer.__init__N)$r+   r,   r-   r.   r/   r0   r9   r1   r:   r;   r=   r   r   r	   r   r   r   r>   r   r
   r   r   rt   ru   r   rp   r   r   r   ZIntegerr   r|   ZRegexr2   r3   rh   r4   r4   r4   r5   r&   b  s~   Ur&   ).r.   r:   Zpygments.lexers.htmlr   r   Zpygments.lexers.javascriptr   Zpygments.lexers.cssr   Zpygments.lexerr   r   r   r	   r
   r   r   r   r   Zpygments.tokenr   r   r   r   r   r   r   r   r   r   Zpygments.utilr   r   __all__r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r4   r4   r4   r5   <module>   s*   
,0!- (:8)o