| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/cygwin64/lib/python3.9/site-packages/docutils/utils/__pycache__/ |
Upload File : |
a
OԼan � @ s� d Z ddlmZ z(ddlZddlmZ ddlmZ dZW n e yN dZY n0 g d�Z
G d d
� d
e�ZG dd� de�Z
G d
d� de�ZdS )z@Lexical analysis of formal languages (i.e. code) using Pygments.� )�ApplicationErrorN)�get_lexer_by_name)�_get_ttype_classTF)�token�text� c @ s e Zd ZdS )�
LexerErrorN)�__name__�
__module__�__qualname__� r r �@/usr/lib/python3.9/site-packages/docutils/utils/code_analyzer.pyr s r c @ s* e Zd ZdZd
dd�Zdd� Zdd� Zd S )�Lexera� Parse `code` lines and yield "classified" tokens.
Arguments
code -- string of source code to parse,
language -- formal language the code is written in,
tokennames -- either 'long', 'short', or 'none' (see below).
Merge subsequent tokens of the same token-type.
Iterating over an instance yields the tokens as ``(tokentype, value)``
tuples. The value of `tokennames` configures the naming of the tokentype:
'long': downcased full token type name,
'short': short name defined by pygments.token.STANDARD_TYPES
(= class argument used in pygments html output),
'none': skip lexical analysis.
�shortc C sp || _ || _|| _d| _|dv s(|dkr,dS ts8td��zt| j�| _W n" tjj yj td| ��Y n0 dS )zE
Set up a lexical analyzer for `code` in `language`.
N)r r Znonez0Cannot analyze code. Pygments package not found.z6Cannot analyze code. No Pygments lexer found for "%s".)
�code�language�
tokennames�lexer�
with_pygmentsr r �pygments�utilZ
ClassNotFound)�selfr r r r r r
�__init__0 s �zLexer.__init__c c sp t |�}t|�\}}|D ].\}}||u r2||7 }q||fV || }}q|�d�r^|dd� }|rl||fV dS )zrMerge subsequent tokens of same token-type.
Also strip the final newline (added by pygments).
�
N���)�iter�next�endswith)r �tokensZlasttypeZlastval�ttype�valuer r r
�mergeK s
zLexer.mergec c s� | j du rg | jfV dS t�| j| j �}| �|�D ]H\}}| jdkrZt|��� �d�}n
t |�g}dd� |D �}||fV q4dS )z7Parse self.code and yield "classified" tokens.
NZlong�.c S s g | ]}|t vr|�qS r )�unstyled_tokens)�.0�clsr r r
�
<listcomp>i � z"Lexer.__iter__.<locals>.<listcomp>)
r r r Zlexr! r �str�lower�splitr )r r Z tokentyper �classesr r r
�__iter__] s
zLexer.__iter__N)r )r r
r �__doc__r r! r, r r r r
r s
r c @ s e Zd ZdZdd� Zdd� ZdS )�NumberLinesaq Insert linenumber-tokens at the start of every code line.
Arguments
tokens -- iterable of ``(classes, value)`` tuples
startline -- first line number
endline -- last line number
Iterating over an instance yields the tokens with a
``(['ln'], '<the line number>')`` token added for every code line.
Multi-line tokens are split.c C s"