Files
intellecton/venv/lib/python3.12/site-packages/pymdownx/__pycache__/highlight.cpython-312.pyc
T

108 lines
24 KiB
Plaintext
Raw Normal View History

Ë
j
Vãó”dZddlZddlmZddlmZddlmcmZddl Z ddl
m Z  ddl m
Z
ddlmZmZddlmZdd l mZeej,d
«dd Dcgc]
}e|«Œ c}«Zed «Zd
Z ej6d«ZdZdZdZdZ idd
dgdddgdddgdddgddd gd!dd"gd#d$d%gd&d'd(gd)d!d*gd+gd,gd-d.d/gd0dd1gd2dd3gd4id5gd6d7d8gd9dd:gd;d7d<gdd=gd
d>gd7d?gd
d@gdAœ¥Z!e rGdB„dCe«Z"GdD„dEe«Z#GdF„dG«Z$GdH„dIe«Z%GdJ„dKe«Z&dL„Z'ycc}w#e$rdZ dZYŒÌwxYw)Ma-
Highlight.
A library for managing code highlighting.
All Changes Copyright 2014-2017 Isaac Muse.
---
CodeHilite Extension for Python-Markdown
========================================
Adds code/syntax highlighting to standard Python-Markdown code blocks.
See <https://pythonhosted.org/Markdown/extensions/code_hilite.html>
for documentation.
Original code Copyright 2006-2008 [Waylan Limberg](https://github.com/waylan).
All changes Copyright 2008-2014 The Python Markdown Project
License: [BSD](http://www.opensource.org/licenses/bsd-license.php)
éN)Ú Extension)Ú
Treeprocessor)Ú OrderedDict)Ú highlight)Úget_lexer_by_nameÚ guess_lexer)Úfind_formatter_class)Ú __version__úÚhtmlTF)rrz^<(div)(\s*class="(.*?)")?\s*>z"<pre{}><code{}{}{}>{}</code></pre>z <pre{}{}{}><code>{}</code></pre>ú class="{}"z id="{}"Ú use_pygmentsz[Use Pygments to highlight code blocks. Disable if using a JavaScript library. Default: TrueÚ
guess_langz-Automatic language detection - Default: FalseÚ css_classrz&CSS class to apply to wrapper element.Úpygments_styleÚdefaultz?Pygments HTML Formatter Style (color scheme) - Default: defaultÚ noclassesz8Use inline styles instead of CSS classes - Default falseÚlinenumszGDisplay line numbers in block code output (not inline) - Default: FalseÚlinenums_styleÚtablez#Line number style -Default: "table"Úlinenums_specialéÿÿÿÿz,Globally make nth line special - Default: -1Úlinenums_classzMControl the linenums class name when not using Pygments - Default: 'linenums'Úextend_pygments_langzBExtend pygments language with special language entry - Default: []Úlanguage_prefixú language-zRControls the language prefix for non-Pygments code blocks. - Defaults: "language-"Úcode_attr_on_prezTAttach attribute list values on pre element instead of code element - Default: FalseÚ
auto_titlezCInject the lexer name as the title for block code - Defaults: FalseÚauto_title_mapzAUser defined mapping of overrides for "auto_title" - Defaults: {}Ú
line_spansÚz£If set to a nonempty string, e.g. foo, the formatter will wrap each output line in a span tag with an id of foo-<code_block_number>-<line_number>. . - Defaults: ""Úanchor_linenumszyIf set to True, will wrap line numbers in <a> tags. Used in combination with linenums and line_anchors. - Defaults: FalseÚ line_anchorsz¯If set to a nonempty string, e.g. foo, the formatter will wrap each output line in an anchor tag with an id (and name) of foo-<code_block_number>-<line_number>. - Defaults: ""zmIf set to True, the language name used will be included as a class attached to the element. - Defaults: FalsezàStrips leading and trailing newlines from code blocks. This is Pygments default behavior. Setting this to False disables this and will retain leading and trailing newlines. This has no affect on inline code. - Defaults: TruezVThe assumed highlight language of a code block when no language is set. - Default textzXUsed internally to communicate if extension has been explicitly enabled - Default: False)Úpygments_lang_classÚstripnlÚ default_langÚ_enabledcó"eZdZdZdZdZdZy)ÚInlineHtmlFormatterzFormat the code blocks.c#ó$K|Ed{y7Œ­w)zDo not wrap with `div`.N©)ÚselfÚinners úU/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pymdownx/highlight.pyÚ _wrap_divzInlineHtmlFormatter._wrap_div“sèø€ð× Ò ús ˆcó$|j|«S)zOverload wrap.)Ú
_wrap_code©r-Úsources r/ÚwrapzInlineHtmlFormatter.wrap˜sð—?? 6Ó c#óXKd|D]\}}||j«fŒdy­w)z6Return source, but do not wrap in inline <code> block.)rr"N)Ústrip)r-r4Úts r/r2zInlineHtmlFormatter._wrap_codes5èø€ðŠKØò
#‘˜Ÿ
Kùs(*N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r0r5r2r,r6r/r*r*sÙ ò

 r6r*cóveZdZdZej
d«Zej
d«ZdZdZ dZ
dZ dZ y )
ÚBlockHtmlFormatterz1Adds ability to output line numbers in a new way.zE(<span[^>]*?)(class="[^"]*\blinenos?\b[^"]*)"([^>]*)>([^<]+)(</span>)z(<pre[^>]*>)(?!<span></span>)c ó†|jdd«dk(|_|jrd|d<tj|fi|¤Žy)ú Initialize.ÚlinenosFzpymdownx-inlineÚinlineN)ÚgetÚpymdownx_inlineÚ
HtmlFormatterÚ__init__)r-Úoptionss r/rHzBlockHtmlFormatter.__init__­sCð$+§;¡;¨y¸%Ó#@ÐDUÑ#Uˆ Ø×#Ø%-˜ Ñ × "  3¨7Ó 3r6cóÆ|jd«|jd«zdz|jd«zdz|jd«zdz|jd«zS) zFormat the custom line number.ér úz data-linenos="éz ">é)Úgroup)r-Úms r/Ú_format_custom_linez&BlockHtmlFormatter._format_custom_lineµsvð˜
ؘ
ñàñð˜
ñð%&§G¡G¨A£Jñ 27ñ 
˜
ñ ð
r6c#ó|K|D]3\}}|r&|jj|j|«}||fŒ5y­w)a
Wrapper to handle block inline line numbers.
For our special inline version, don't display line numbers via `<span> 1</span>`,
but include as `<span data-linenos=" 1"></span>` and use CSS to display them:
`[data-linenos]:before {content: attr(data-linenos);}`. This allows us to use
inline and copy and paste without issue.
N)Ú RE_SPAN_NUMSÚsubrR©r-r.r:Úlines r/Ú_wrap_customlinenumsz'BlockHtmlFormatter._wrap_customlinenumsÆsEèø€ð
Ø××1IÑ1IÈ4ÓP˜g“
ñ
ùs:<có†|jdk(r|jr|j|«}tj ||«S)zWrap the source code.r )rCrFrXrGr5r3s r/r5zBlockHtmlFormatter.wrapÕs;ð|‰|˜qÒ  T×%9Ò%9Ø×2°6Ó:Ü ×% d¨FÓ 3r6c#óˆKtj||«D]%\}}||jjd|«fŒ'y­w)aC
Wrapper to handle line numbers better in table.
Pygments currently has a bug with line step where leading blank lines collapse.
Use the same fix Pygments uses for code content for code line numbers.
This fix should be pull requested on the Pygments repository.
z\1<span></span>N)rGÚ_wrap_tablelinenosÚ
RE_TABLE_NUMSrUrVs r/r[z%BlockHtmlFormatter._wrap_tablelinenosÜsIèø€ô;¸DÀ%Ó
J˜×/Ð0BÀDÓ
JùsAAN)
r;r<r=r>ÚreÚcompilerTr\rHrRrXr5r[r,r6r/r@r@¥sCÙ"r—zzÐ"jÓkˆ à"˜Ÿ
Ð#CÓDˆ
ò ò"
ò
Jr6r@cóDeZdZdZ ddZdZdZdZ d dZy)
Ú HighlightzHighlight class.NcóZ||_||_||_||_||_||_||_| |_|
|_| |_ | |_
||_ ||_ ||_
||_||_||_|jr|jsd|_ |
i}
|
|_|g}i|_|D]z}t'|t(t*f«sŒ|j-d«}|Œ.||j$vsŒ=|j-d«|j-di«g|j$|j/«<Œ|y)rBÚ __codelinenoNÚnameÚlangrI)rrrrrrrrrrrr!r$r#r%r&r'r rÚ
isinstanceÚdictrrEÚlower)r-rrrrrrrrrrrrr r!r#r$r%r&r'Úlanguagercs r/rHzHighlight.__init__ìs7ðŒØÔØÔØŒØ ˆŒ
ØÔØ 0ˆÔØÔØÔØ 0ˆÔ،،ØÔØÔØ#6ˆÔ ؈Œ ØÔà × Ò ¨×(9Ò(9Ø .ˆDÔ à Ð ˆNØÔà Ð 'Ø#%Ð Ø$&ˆÔ ˆ˜(¤T¬;Ð$7Õ—|‘| FÓ+ØÑ°D×4MÑ4MÒ(Mà Ÿ  VÓ Ÿ  Y°Ó?-¨d¯j©j«lÒ r6cóZ|jj|j«|if«S)zGet extended language.)rrErg)r-rhs r/Úget_extended_languagezHighlight.get_extended_languages(ð×(×,¨X¯^©^Ó-=ÀÈ"¸Nr6có®|}d|i}|r%|j|«\}}|j|« t|fi|¤Ž}|€K|jdus!|r|jdk(r,n|jdk(r t |fi|¤Ž}|j d}|€)t|jxsdfi|¤Ž}|j d}||fS#t$rd}YŒ‰wxYw#t$rYŒKwxYw)zGet the Pygments lexer.r&NTrDÚblockrÚtext)rjÚupdaterÚ ExceptionrrÚaliasesr') r-ÚsrcrhrDr&rcÚ
lexer_optionsrIÚlexers r/Ú get_lexerzHighlight.get_lexer sðˆà" ,ˆ
Ù Ø $× :Ñ :¸8Ó DÑ ˆH × Ñ  Ô  Ü% hÑ@°-Ñ@ˆEð ˆ 4Ñ'ÉF¨T¯_©_ÀÓ-HÐX\×XgÑXgÐkrÒXrðÜÑ=¨}Ñ= Ÿ=™=¨Ñ+ ˆ% d×&7Ñ&7Ò&A¸SÀ]ÑSˆ—=‘= Ñ#ˆDØdˆ{Ðøôò ØŠEð ûôÙðús#¯ B7Á-CÂ7 CÃCà CÃCcór|jdd«}|jdd«}|jdd«}|S)zBasic HTML escaping.ú&amp;ú&lt;ú&gt;©Úreplace)r-Útxts r/ÚescapezHighlight.escape<s9ðk‰k˜#˜'ˆØk‰k˜#˜&ˆØk‰k˜#˜&ˆØˆ
r6có
| i} | r| ddng}|jxr|dk7xs|jduxr|dkDxr|dkD }d}|s|jr |j}trÈ|jr»tdkr t d«|rd}n |j }|j||||«\}}|jr|jd|j|z«|r |jnd}|r=|r;dj|sdn|«}d j|«|z}|j«}|}|
rtj|
«nd}|
r|
n
t!|
«}| sd}n[g}| j#«D].\}}|j%d
«sŒ|j'|d |d «Œ0|rd d j|«znd}|r|d
krd
}|r|d
krd
}|j(dk\r|dkr |j(}|r|dkrd}||rg}| |j*rsd j|j,j/«Dcgc]$}|j1«r|j3«n|Œ&c}«}|j4j7||«} | r| j«} | d} |rt8nt:}|||||||j<|j>|d|s| nd|j@r|s|j@d|nd|jBr|s|jBd|nd|s |jDnd¬«
}tG|||«} |r|}d}nŽtHjK| «}!|!v|!jMd«}"|!jOd«}#|rq|!jQd«r?djd j|«|!jQd«j««} nVdjd j|««} n5|!jQd«r"d |!jQd«jS«znd} | d|#d|!jQd
«|| |d| |"d} n…|r_|jU|«} |r|jd|«|r|jd|j|z«|rd j|«nd}|
}n$|jVr|r|jd|«|r|jd|j|z«|r$tXjd j|««nd}|
rtj|