3
.ßL]%Q  ã               @   sn  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  d	d
dddddddddg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-2019 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ÚMarkdownLexerc               @   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\[z\s+z(\w+)(=)("?[^\s"\]]+"?)z(=)("?[^\s"\]]+"?)z\]z#pop)Úrootr&   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚaliasesÚ	mimetypesr   r   r	   r   Ú	Attributer   r   Útokens© r1   r1   ú</tmp/pip-install-5sebvq2j/pygments/pygments/lexers/markup.pyr      s   
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\'\[{!_~^,|]+z\nÚ.z\}\}\}z#popz\{\{\{z#pushz[^{}]+)r'   r3   N)r(   r)   r*   r+   r,   r-   Ú	filenamesr.   ÚreÚ	MULTILINEÚ
IGNORECASEÚflagsr   r	   r   r   r   ÚHeadingr
   r   r   r   ÚBuiltinÚ	NamespaceÚPreprocr0   r1   r1   r1   r2   r   ?   s2   
c               @   s�  e Zd ZdZdZdddgZddgZdd	gZej	Z
d
d„ ZdZdZdejeƒej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jeejƒ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d0e fd$e e d1fd2e fgd3œZ(d4d5„ Z)d6d7„ Z*d8S )9r   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reStructuredTextZrstÚrestZrestructuredtextz*.rstz*.restz
text/x-rstztext/prs.fallenstein.rstc             c   sÒ  ddl m} |jdƒt|jdƒfV  |jdƒt|jdƒfV  |jdƒtj|jdƒfV  |jdƒt|jdƒfV  |jdƒt|jdƒfV  |jdƒt|jdƒfV  |jd	ƒt|jd	ƒfV  d }| j	rìy||jdƒj
ƒ ƒ}W n tk
rê   Y nX |jd
ƒ}t|ƒ}||jdƒ |jdƒ |jdƒ }|d k�r@|jd
ƒt|fV  d S g }|jdƒ}d}xX|D ]P}	t|	ƒ|k�rž|jt|ƒdt|	d |… fgfƒ ||	|d … 7 }n||	7 }�qXW x t||j|ƒƒD ]}
|
V  �q¾W d S )Nr   )Úget_lexer_by_nameé   é   é   é   é   é   é   é   é	   é
   é   TÚ )Úpygments.lexersr?   Ústartr   Úgroupr   r   ÚWordr   ÚhandlecodeblocksÚstripr   Úlenr   Ú
splitlinesÚappendr   Úget_tokens_unprocessed)ÚselfÚmatchr?   ÚlexerZ	indentionZindention_sizeÚcodeZinsZ	codelinesÚlineÚitemr1   r1   r2   Ú_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^( *)(:[a-zA-Z-]+:)(\s*)$z^( *)(:.*?:)([ \t]+)(.*?)$z!^(\S.*(?<!::)\n)((?:(?: +.*)\n)+)z2(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*|)\n)+)z\\.z``Úliteralz(`.+?)(<.+?>)(`__?)z`.+?`__?z(`.+?`)(:[a-zA-Z0-9:-]+?:)?z(:[a-zA-Z0-9:-]+?:)(`.+?`)z\*\*.+?\*\*z\*.+?\*z\[.*?\]_z<.+?>z[^\\\n\[*`:]+r4   z[^`]+z#popú`)r'   r]   r_   c             K   s    t |ddƒ| _tj| f|Ž d S )NrP   T)r   rP   r   Ú__init__)rV   Úoptionsr1   r1   r2   ra     s    zRstLexer.__init__c             C   s†   | d d… dkr$| dd… dkr$dS | j dƒ}| j d|d ƒ}|d
kr‚|d d |kr‚| |d  dkr‚| |d  | |d  kr‚d	S d S )NrA   z..rB   r4   g333333Ó?Ú
r@   z-=g      à?éÿÿÿÿ)Úfind)ÚtextÚp1Úp2r1   r1   r2   Úanalyse_text	  s     
zRstLexer.analyse_textN)+r(   r)   r*   r+   r,   r-   r5   r.   r6   r7   r9   r\   ZclosersZunicode_delimitersÚescapeZend_string_suffixr	   r   r:   r   r   r
   r   r   r   rO   r   ÚTagr   r=   ÚClassZFunctionr   ÚEscaper   ZInterpolÚVariabler/   ÚStrongÚEmphr0   ra   ri   r1   r1   r1   r2   r   l   sŒ   
*c            
   @   s  e Zd ZdZdZddgZdddg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latexz*.texz*.auxz*.tocz
text/x-texztext/x-latexz%.*?\nz[{}]z[&_^]z\\\[Údisplaymathz\\\(Ú
inlinemathz\$\$z\$z\\([a-zA-Z]+|.)Úcommandz\\$Úgeneralz[^\\$%&_^{}]+z[0-9]+z[-=!+*/()\[\]]z[^=!+*/()\[\]\\$%&_^{}0-9-]+z\\\)z#popÚmathz\\\]z\[.*?\]z\*)rt   r'   ru   rr   rq   rs   c             C   s*   x$dD ]}| d t |ƒ… |krdS qW d S )Nú\documentclassú\inputú\documentstyleú\relaxT)rv   rw   rx   ry   )rR   )rf   rM   r1   r1   r2   ri   H  s    zTexLexer.analyse_textN)r(   r)   r*   r+   r,   r-   r5   r.   r   r   r;   r   ÚBacktickr   r   r   rn   r   r   r/   r   r0   ri   r1   r1   r1   r2   r     s@   




c            
   @   sÒ   e Zd ZdZdZdddg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GroffZgroffZnroffZmanz*.[1234567]z*.manzapplication/x-troffz
text/troffz	(\.)(\w+)Úrequestz\.z[^\\\n]+ÚtextlineÚescapesz\nz#popz	\\"[^\n]*z\\[fn]\wz\\\(.{2}z	\\.\[.*\]z\\.z\\\nz	"[^\n"]+"z\d+z\S+z\s+)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… j ƒ r\| d jƒ r\d	S d S )
Nr@   r4   FrB   z.\"TrC   z.TH gÍÌÌÌÌÌì?)ÚisalnumÚisspace)rf   r1   r1   r2   ri   |  s    zGroffLexer.analyse_textN)r(   r)   r*   r+   r,   r-   r5   r.   r	   r   r   r   r   r   r   r   rm   ÚDoubler   r0   ri   r1   r1   r1   r2   r   O  s2   


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Ú	exprstartz.+z(literal)(.*)z#pop:2ÚdefineÚundefÚifÚifdefÚifndefÚelseÚelifÚelifdefÚelifndefÚendifÚexpandÚfilterÚunfilterr   ÚincludesubstÚerrorz#popú!ú!=ú==ú&&ú||z(defined)(\()z\)z[0-9]+z__\w+?__z@\w+?@z\w+z\nz\s+z\S)r'   r‚   r�   N)r�   r‚   )rƒ   r„   r…   r†   r‡   rˆ   r‰   rŠ   r‹   rŒ   r�   rŽ   r�   r   r�   r‘   )r’   r“   r”   r•   r–   )r(   r)   r*   r+   r,   r-   r5   r.   r   r=   r   r	   r   r   r   r   r   r   ÚDecimalr   rn   rl   r0   r1   r1   r1   r2   r    ‡  s.   
  

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‚   z.+N)r�   r‚   )r(   r)   r*   r+   r,   r-   r5   r.   r   r=   r   r0   r1   r1   r1   r2   r!   °  s   
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 t| ƒjttf|Ž d S )N)Úsuperr"   ra   r   r    )rV   rb   )Ú	__class__r1   r2   ra   Ñ  s    
zMozPreprocXulLexer.__init__)
r(   r)   r*   r+   r,   r-   r5   r.   ra   Ú__classcell__r1   r1   )r™   r2   r"   Å  s   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 t| ƒjttf|Ž d S )N)r˜   r#   ra   r   r    )rV   rb   )r™   r1   r2   ra   â  s    
z"MozPreprocJavascriptLexer.__init__)
r(   r)   r*   r+   r,   r-   r5   r.   ra   rš   r1   r1   )r™   r2   r#   Ö  s   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 t| ƒjttf|Ž d S )N)r˜   r$   ra   r   r!   )rV   rb   )r™   r1   r2   ra   ó  s    
zMozPreprocCssLexer.__init__)
r(   r)   r*   r+   r,   r-   r5   r.   ra   rš   r1   r1   )r™   r2   r$   ç  s   c               @   sh  e Zd ZdZdZdgZ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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eeeƒfdefedƒg	defdeeejeƒfdeeejdeƒfdeeejeƒfd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text/x-markdownc             c   sì   ddl m} |jdƒt|jdƒfV  |jdƒt|jdƒfV  |jdƒt|jdƒfV  d}| jrŠy||jdƒjƒ ƒ}W n tk
rˆ   Y nX |jdƒ}|dkr°|jdƒt|fV  n xt	g |j
|ƒƒD ]
}|V  qÂW |jdƒt|jdƒfV  dS )	zV
        match args: 1:backticks, 2:lang_name, 3:newline, 4:code, 5:backticks
        r   )r?   r@   rA   rB   NrC   rD   )rL   r?   rM   r   rN   r   rP   rQ   r   r   rU   )rV   rW   r?   rX   rY   r[   r1   r1   r2   Ú_handle_codeblock  s     

zMarkdownLexer._handle_codeblockz^(#)([^#].+\n)z^(#{2,6})(.+\n)z^(\s*)([*-] )(\[[ xX]\])( .+\n)r]   )r^   z^(\s*)([*-])(\s)(.+\n)z^(\s*)([0-9]+\.)( .+\n)z^(\s*>\s)(.+\n)z^(```\n)([\w\W]*?)(^```$)z ^(```)(\w+)(\n)([\w\W]*?)(^```$)z\\.z(\s)([*_][^*_]+[*_])(\W|\n)z(\s)((\*\*|__).*\3)((?=\W|\n))Nz(\s)(~~[^~]+~~)((?=\W|\n))z`[^`]+`z[@#][\w/:]+z (!?\[)([^]]+)(\])(\()([^)]+)(\))z(\[)([^]]+)(\])(\[)([^]]*)(\])z^(\s*\[)([^]]*)(\]:\s*)(.+)z[^\\\s]+r4   )r'   r]   c             K   s    t |ddƒ| _tj| f|Ž d S )NrP   T)r   rP   r   ra   )rV   rb   r1   r1   r2   ra   U  s    zMarkdownLexer.__init__)!r(   r)   r*   r+   r,   r-   r5   r.   r6   r7   r9   r›   r	   r   r:   r   Z
Subheadingr   r
   r   rp   r   r   ro   ZDeletedrz   r   ÚEntityrk   r/   ZLabelr0   ra   r1   r1   r1   r2   r%   ø  s>    )-r+   r6   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%   r1   r1   r1   r2   Ú<module>
   s.   ,0
!- *:8)