File: //usr/lib/python3/dist-packages/pygments/lexers/__pycache__/templates.cpython-310.pyc
o
���a� � @ s8 d Z ddlZddlmZmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZmZ dd
lmZ ddlmZmZmZmZmZmZmZmZmZ ddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ dd
l,m-Z-m.Z. g d�Z/G dd� de�Z0G dd� de�Z1G dd� de�Z2G dd� de�Z3G dd� de�Z4G dd� de�Z5G dd� de�Z6G dd� de�Z7G dd � d e�Z8G d!d"� d"e�Z9G 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/d0� d0e�Z@G d1d2� d2e�ZAG d3d4� d4e�ZBG d5d6� d6e�ZCG d7d8� d8e�ZDG d9d:� d:e�ZEG d;d<� d<e�ZFG d=d>� d>e�ZGG d?d@� d@e�ZHG dAdB� dBe�ZIG dCdD� dDe�ZJG dEdF� dFe�ZKG dGdH� dHe�ZLG dIdJ� dJe�ZMG dKdL� dLe�ZNG dMdN� dNe�ZOG dOdP� dPe�ZPG dQdR� dRe�ZQG dSdT� dTe�ZRG dUdV� dVe�ZSG dWdX� dXe�ZTG dYdZ� dZe�ZUG d[d\� d\e�ZVG d]d^� d^e�ZWG d_d`� d`e�ZXG dadb� dbe�ZYG dcdd� dde�ZZG dedf� dfe�Z[G dgdh� dhe�Z\G didj� dje�Z]G dkdl� dle�Z^G dmdn� dne�Z_G dodp� dpe�Z`G dqdr� dre�ZaG dsdt� dte�ZbG dudv� dve�ZcG dwdx� dxe�ZdG dydz� dze�ZeG d{d|� d|e�ZfG d}d~� d~e�ZgG dd�� d�e�ZhG d�d�� d�e�ZiG d�d�� d�e�ZjG d�d�� d�e�ZkG d�d�� d�e�ZlG d�d�� d�e�ZmG d�d�� d�e�ZnG d�d�� d�e�ZoG d�d�� d�e�ZpG d�d�� d�e�ZqG d�d�� d�e�ZrG d�d�� d�e�ZsdS )�z�
pygments.lexers.templates
~~~~~~~~~~~~~~~~~~~~~~~~~
Lexers for various template engines' markup.
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)� HtmlLexer�XmlLexer)�JavascriptLexer�
LassoLexer)�CssLexer)�PhpLexer)�PythonLexer)� PerlLexer)� JavaLexer�TeaLangLexer)� YamlLexer) �Lexer�DelegatingLexer�
RegexLexer�bygroups�include�using�this�default�combined)�Error�Punctuation�
Whitespace�Text�Comment�Operator�Keyword�Name�String�Number�Other�Token)�html_doctype_matches�looks_like_xml)?�HtmlPhpLexer�XmlPhpLexer�CssPhpLexer�JavascriptPhpLexer�ErbLexer�
RhtmlLexer�XmlErbLexer�CssErbLexer�JavascriptErbLexer�SmartyLexer�HtmlSmartyLexer�XmlSmartyLexer�CssSmartyLexer�JavascriptSmartyLexer�DjangoLexer�HtmlDjangoLexer�CssDjangoLexer�XmlDjangoLexer�JavascriptDjangoLexer�GenshiLexer�HtmlGenshiLexer�GenshiTextLexer�CssGenshiLexer�JavascriptGenshiLexer�MyghtyLexer�MyghtyHtmlLexer�MyghtyXmlLexer�MyghtyCssLexer�MyghtyJavascriptLexer�
MasonLexer� MakoLexer�
MakoHtmlLexer�MakoXmlLexer�MakoJavascriptLexer�MakoCssLexer�JspLexer�CheetahLexer�CheetahHtmlLexer�CheetahXmlLexer�CheetahJavascriptLexer�EvoqueLexer�EvoqueHtmlLexer�EvoqueXmlLexer�ColdfusionLexer�ColdfusionHtmlLexer�ColdfusionCFCLexer�
VelocityLexer�VelocityHtmlLexer�VelocityXmlLexer�SspLexer�TeaTemplateLexer�LassoHtmlLexer�
LassoXmlLexer�
LassoCssLexer�LassoJavascriptLexer�HandlebarsLexer�HandlebarsHtmlLexer�YamlJinjaLexer�LiquidLexer� TwigLexer�
TwigHtmlLexer�
Angular2Lexer�Angular2HtmlLexerc @ sF e Zd ZdZdZdgZdgZe�dej �Z
dd� Zdd � Zd
d� Z
dS )
r( a
Generic `ERB <http://ruby-doc.org/core/classes/ERB.html>`_ (Ruby Templating)
lexer.
Just highlights ruby code between the preprocessor directives, other data
is left untouched by the lexer.
All options are also forwarded to the `RubyLexer`.
�ERB�erbzapplication/x-ruby-templatingz*(<%%|%%>|<%=|<%#|<%-|<%|-%>|%>|^%[^%].*?$)c K s2 ddl m} |di |��| _tj| fi |�� d S )Nr )� RubyLexer� )�pygments.lexers.rubyre �
ruby_lexerr
�__init__)�self�optionsre rf rf �;/usr/lib/python3/dist-packages/pygments/lexers/templates.pyri B s zErbLexer.__init__c c s � | j �|�}|�� d }}z� |dkr(|�� }|t|fV |t|�7 }d}n�|dkr�|�� }|dv rA|t|fV |d7 }d}n�|dkrc|tj|fV |�� }|d t|fV |dt|� 7 }d}n�|dv r�|tj|fV |t|�7 }|�� }d}| j� |�D ]
\}} }
|| | |
fV q�|t|�7 }d}nc|d v r�|t
|fV |t|�7 }d}nP|tj|d fV d}| j� |dd
� �D ]\}} }
|d | | |
fV q�|t|�7 }d}n"|dkr�|�� }|d vr�|t|fV n|tj|fV |t|�7 }d}q t�y Y d
S w )z�
Since ERB doesn't allow "<%" and other tags inside of ruby
blocks we have to use a split approach here that fails for
that too.
r T� )z<%%z%%>� z<%#� )�<%z<%=z<%-)�%>z-%>N)� _block_re�split�reverse�popr �lenr �Preprocrh �get_tokens_unprocessedr �
IndexError)rj �text�tokens�state�idx�val�tag�data�r_idx�r_token�r_valuerf rf rl rx G sn �
���7�zErbLexer.get_tokens_unprocessedc C s d| v r
d| v rdS d S d S )Nrp rq 皙�����?rf �rz rf rf rl �analyse_text� s �zErbLexer.analyse_textN)�__name__�
__module__�__qualname__�__doc__�name�aliases� mimetypes�re�compile�Mrr ri rx r� rf rf rf rl r( 1 s
Dr( c
@ s� e Zd ZdZdZdgZdgZdgZej ej
B Zdefde
ejeej�fde
ejeed d
�ej�fde
ejeje�dfdejdfgd
efdejdfdejdfdejfdejfdefdejfdefdejfdejfdejfgd�Zdd� ZdS )r- z�
Generic `Smarty <http://smarty.php.net/>`_ template lexer.
Just highlights smarty code between the preprocessor directives, other
data is left untouched by the lexer.
�Smarty�smarty�*.tplzapplication/x-smarty�[^{]+z(\{)(\*.*?\*)(\})z(\{php\})(.*?)(\{/php\})T)�startinlinez(\{)(/?[a-zA-Z_]\w*)(\s*)�\{�\s+�#push�\}�#popz#[a-zA-Z_]\w*#z\$[a-zA-Z_]\w*(\.\w+)*z[~!%^&*()+=|\[\]:;,.<>/?@-]�(true|false|null)\b�>[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?�"(\\\\|\\[^\\]|[^"\\])*"�'(\\\\|\\[^\\]|[^'\\])*'�[a-zA-Z_]\w*)�rootr� c C sX d}t �d| �r|d7 }t �d| �r|d7 }t �d| �r |d7 }t �d| �r*|d7 }|S )N� z\{if\s+.*?\}.*?\{/if\}�333333�?z\{include\s+file=.*?\}z \{foreach\s+.*?\}.*?\{/foreach\}z \{\$.*?\}�{�G�z�?�r� �search�rz �rvrf rf rl r� � s zSmartyLexer.analyse_textN) r� r� r� r� r� r� � filenamesr� r� � MULTILINE�DOTALL�flagsr r r rw r r r �Functionr �Variabler r �Constantr r �Double�Single� Attributer{ r� rf rf rf rl r- � sJ ����
�
���r- c @ s� e Zd ZdZdZdgZddgZejej B Z
dZdefde
ejeej�fd e
eje�fd
e d e
ejejeje�dfd
e d
e
ejejej�fdedfgeejfdedfde d e
eej�dfdedfed�gdefdedfde d ejfed�gdefed�dedfgdedfdefdefdejfd ejfd!efd"efd#ejfdedfd$edfd%edfdedfdedfdedfgd&�Zd'd(� Zd)S )*rR z�
Generic `Velocity <http://velocity.apache.org/>`_ template lexer.
Just highlights velocity directives and variable references, other
data is left untouched by the lexer.
�Velocity�velocity�*.vm�*.fhtmlr� z[^{#$]+z(#)(\*.*?\*)(#)z
(##)(.*?$)z(#\{?)(z
)(\}?)(\s?\()�directiveparamsz)(\}|\b)z\$!?\{?�variablez\(�
funcparamsz(\.)(�)r� r� r� z=(&&|\|\||==?|!=?|[-<>+*%&|^/])|\b(eq|ne|gt|lt|ge|le|not|in)\bz\[�
rangeoperatorz\bz\.\.z\]r� z[,:]r� r� z0[xX][0-9a-fA-F]+[Ll]?z
\b[0-9]+\br� �\)r� )r� r� r� r� r� c C sd d}t �d| t j�r|d7 }t �d| t j�r|d7 }t �d| t j�r&|d7 }t �d| �r0|d7 }|S ) Nr� z #\{?macro\}?\(.*?\).*?#\{?end\}?g �?z#\{?if\}?\(.+?\).*?#\{?end\}?r� z"#\{?foreach\}?\(.+?\).*?#\{?end\}?z6\$!?\{?[a-zA-Z_]\w*(\([^)]*\))?(\.\w+(\([^)]*\))?)*\}?r� �r� r� r� r� rf rf rl r� s �zVelocityLexer.analyse_textN) r� r� r� r� r� r� r� r� r� r� r� �
identifierr r r rw r r� r r� r r r r r r� r� r r r� r{ r� rf rf rf rl rR � sv �
�
�
��
�� �����4rR c �8 e Zd ZdZdZdgZddgZdgZ� fdd�Z� Z S ) rS za
Subclass of the `VelocityLexer` that highlights unlexed data
with the `HtmlLexer`.
z
HTML+Velocityz
html+velocity�*.htmlr� ztext/html+velocityc � t � jttfi |�� d S �N)�superri r rR �rj rk �� __class__rf rl ri & � zVelocityHtmlLexer.__init__)
r� r� r� r� r� r� �alias_filenamesr� ri �
__classcell__rf rf r� rl rS s rS c �@ e Zd ZdZdZdgZddgZdgZ� fdd�Zd d
� Z � Z
S )rT z`
Subclass of the `VelocityLexer` that highlights unlexed data
with the `XmlLexer`.
zXML+Velocityzxml+velocity�*.xmlr� zapplication/xml+velocityc r� r� )r� ri r rR r� r� rf rl ri 6 r� zVelocityXmlLexer.__init__c C �"