%PDF- %PDF-
| Direktori : /lib/python3/dist-packages/markdown/extensions/__pycache__/ |
| Current File : //lib/python3/dist-packages/markdown/extensions/__pycache__/codehilite.cpython-312.pyc |
�
���e�4 � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
mZmZ e
r dd l
mc mZ dd
lmZ ddlmZmZ ddlmZ dd
lmZ dZdd�Z G d� d� Z G d� de� Z G d� de� Zd� Zy # e$ r dZY �1w xY w)z�
Adds code/syntax highlighting to standard Python-Markdown code blocks.
See the [documentation](https://Python-Markdown.github.io/extensions/code_hilite)
for details.
� )�annotations� )� Extension� )�
Treeprocessor)�parseBoolValue)�
TYPE_CHECKING�Callable�AnyN)� highlight)�get_lexer_by_name�guess_lexer)�get_formatter_by_name)�
ClassNotFoundTFc �| � | sg S t t t | j � � � S # t $ r g cY S w xY w)z�Support our syntax for emphasizing certain lines of code.
`expr` should be like '1 2' to emphasize lines 1 and 2 of a code block.
Returns a list of integers, the line numbers to emphasize.
)�list�map�int�split�
ValueError)�exprs �@/usr/lib/python3/dist-packages/markdown/extensions/codehilite.py�parse_hl_linesr * s= � � �� ���C��T�Z�Z�\�*�+�+��� �� ��s �&- �;�;c �* � e Zd ZdZdd�Zddd�Zd d�Zy)
�
CodeHiliteau
Determine language of source code, and pass it on to the Pygments highlighter.
Usage:
```python
code = CodeHilite(src=some_code, lang='python')
html = code.hilite()
```
Arguments:
src: Source string or any object with a `.readline` attribute.
Keyword arguments:
lang (str): String name of Pygments lexer to use for highlighting. Default: `None`.
guess_lang (bool): Auto-detect which lexer to use.
Ignored if `lang` is set to a valid value. Default: `True`.
use_pygments (bool): Pass code to Pygments for code highlighting. If `False`, the code is
instead wrapped for highlighting by a JavaScript library. Default: `True`.
pygments_formatter (str): The name of a Pygments formatter or a formatter class used for
highlighting the code blocks. Default: `html`.
linenums (bool): An alias to Pygments `linenos` formatter option. Default: `None`.
css_class (str): An alias to Pygments `cssclass` formatter option. Default: 'codehilite'.
lang_prefix (str): Prefix prepended to the language. Default: "language-".
Other Options:
Any other options are accepted and passed on to the lexer and formatter. Therefore,
valid options include any options which are accepted by the `html` formatter or
whichever lexer the code's language uses. Note that most lexers do not have any
options. However, a few have very useful options, such as PHP's `startinline` option.
Any invalid options are ignored without error.
* **Formatter options**: <https://pygments.org/docs/formatters/#HtmlFormatter>
* **Lexer Options**: <https://pygments.org/docs/lexers/>
Additionally, when Pygments is enabled, the code's language is passed to the
formatter as an extra option `lang_str`, whose value being `{lang_prefix}{lang}`.
This option has no effect to the Pygments' builtin formatters.
Advanced Usage:
```python
code = CodeHilite(
src = some_code,
lang = 'php',
startinline = True, # Lexer option. Snippet does not start with `<?php`.
linenostart = 42, # Formatter option. Snippet starts on line 42.
hl_lines = [45, 49, 50], # Formatter option. Highlight lines 45, 49, and 50.
linenos = 'inline' # Formatter option. Avoid alignment problems.
)
html = code.hilite()
```
c � � || _ |j dd � | _ |j dd� | _ |j dd� | _ |j dd� | _ |j dd� | _ d |vr|j d
d � |d <