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

136 lines
10 KiB
Plaintext
Raw Normal View History

Ë
jGãóFdZddlZddlmZddlmZddlmZddlm cm
Z ddl mZddl m Z
ddlZdZd Zej"d
«Zej"d «Zd j)ej*ed
«ej.«ZdZGdde«ZGdde«ZdZy)
Keys.
pymdownx.keys
Markdown extension for keystroke (user keyboard input) formatting.
It wraps the syntax `++key+key+key++` (for individual keystrokes with modifiers)
or `++"string"++` (for continuous keyboard input) into HTML `<kbd>` elements.
If a key is found in the extension's database, its `<kbd>` element gets a matching class.
Common synonyms are included, e.g. `++pg-up++` will match as `++page-up++`.
## Config
If `strict` is `True`, the entire series of keystrokes is wrapped into an outer`<kbd>` element, and then,
each keystroke is wrapped into a separate inner `<kbd>` element, which matches the HTML5 spec.
If `strict` is `False`, an outer `<span>` is used, which matches the practice on Github or StackOverflow.
The resulting `<kbd>` elements are separated by `separator` (`+` by default, can be `''` or something else).
If `camel_case` is `True`, `++PageUp++` will match the same as `++page-up++`.
The database can be extended or modified with the `key_map` dict.
## Examples
### Input
```
Press ++Shift+Alt+PgUp++, type in ++"Hello"++ and press ++Enter++.
```
### Config 1
```
pymdownx.keys:
camel_case: true
strict: false
separator: '+'
```
### Output 1
```
<p>Press <span class="keys"><kbd class="key-shift">Shift</kbd><span>+</span><kbd
class="key-alt">Alt</kbd><span>+</span><kbd class="key-page-up">Page Up</kbd></span>, type in <span
class="keys"><kbd>Hello</kbd></span> and press <span class="keys"><kbd class="key-enter">Enter</kbd></span>.</p>
```
### Config 2
```
pymdownx.keys:
camel_case: true
strict: true
separator: ''
```
### Output 2
```
<p>Press <kbd class="keys"><kbd class="key-shift">Shift</kbd><kbd class="key-alt">Alt</kbd><kbd
class="key-page-up">Page Up</kbd></kbd>, type in <kbd class="keys"><kbd>Hello</kbd></kbd> and press <kbd
class="keys"><kbd class="key-enter">Enter</kbd></kbd>.</p>
```
Idea by Adam Twardoch and coded by Isaac Muse.
Copyright (c) 2017 Isaac Muse <isaacmuse@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
éN)Ú Extension)ÚInlineProcessor)Úutilé)Ú keymap_dbzé(?x)
(?:
# Escape
(?<!\\)(?P<escapes>(?:\\{2})+)(?=\+)|
# Key
(?<!\\)\+{2}
(
(?:(?:[\w\-]+|"(?:\\.|[^"])+"|\'(?:\\.|[^\'])+\')\+)*?
(?:[\w\-]+|"(?:\\.|[^"])+"|\'(?:\\.|[^\'])+\')
)
\+{2}
)
z"\+{2}([\w\-]+(?:\+[\w\-]+)*?)\+{2}z(?<!\\)(?:\\\\)*\\(.)z(?<!\\)(?:\\\\)*(\+)z{}{}{}ú\z\\có<eZdZdZdˆfd„ ZdZdZdZdZˆxZ S)Ú KeysPatternzReturn kbd tag.có|d|_|d|_|djd«|_|j t
j
|d«|_t
j|_|d|_||_ t|-||«y)ú Initialize.Ú separatorÚstrictÚclassú Úkey_mapÚ
camel_caseN) ÚkseprÚsplitÚclassesÚmergeÚkeymapÚmapÚaliasesÚcamelÚearlyÚsuperÚ__init__)ÚselfÚpatternÚconfigÚmdrÚ __class__s €úP/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pymdownx/keys.pyrzKeysPattern.__init__ws{ø€ð˜'ˆŒ ؘ&ˆŒ ؘg‘×,¨SÓŒ Ø—:‘:œfŸm™m¨V°IÑ->ӌܗ~‘~ˆŒ ؘLÑŒ
؈Œ
Ü
ј cóH|j«}|j|«|S)z,Given two dicts, merge them into a new dict.)ÚcopyÚupdate)rÚzs r#rzKeysPattern.mergeƒsð
F‰F‹HˆØ Œ ؈r$có.|js|Sg}d}|D]n}|j«rI|r|dk(r |j|j««n3|j d|j«g«n|j|«|}Œpdj |«S)zNormalize the value.Úú-)rÚisupperÚappendÚlowerÚextendÚjoin)rÚkeyÚnorm_keyÚlastÚcs r#Ú normalizezKeysPattern.normalizeŠs†ðzŠz؈JàˆØˆØò ˆAØy‰yŒ{Ù˜t sš{Ø—O‘O A§G¡G£IÕ—OO S¨!¯'©'«)Ð$4Õ Ô‰Dð ðw‰w Ð r$c óF|jd«r>dtjtj d|dd««j «f}|S|j
|«}|jj||«}|jj|d«}|r||fnd}|S)z Process key.©ú'Nz\1réÿÿÿÿ)
Ú
startswithÚhtmlÚunescapeÚ ESCAPE_REÚsubÚstripr7rÚgetr)rr3Úvaluer4Ú
canonical_keyÚnames r#Ú process_keyzKeysPattern.process_keysð >‰>˜ œ4Ÿ=™=¬¯©°u¸cÀ!ÀB¸iÓ)HÓRˆEð ˆ ð —~‘~ cÓ*ˆHØ ŸL™L×,¨X°xÓ@ˆ—88—<< 
¨tÓ4ˆDÙ-1] )°tˆˆ r$có‚|jrÇ|jd«rJ|jd«jtt«|j d«|j
d«fSd}g}tj|jd««D]>}|dk7sŒ |jd«r|dz
}|j|j|««Œ@|s=y|jd«jd«Dcgc]}|j|«Œ}}d|vrytj|jrd nd
|jrd d j!|j«ini«}d}|D\}} g}
|r|
jd
|z«|F|j"r:tj$|d
«} t'j(|j"«| _i} |
rd j!|
«| d <tj$|d | «}
t'j(| «|
_|
}Œ²||j d«|j
d«fScc}w)zHandle kbd pattern matches.rÚescapesréú+r9)NNNNÚkbdÚspanrrzkey-)rÚgroupÚreplaceÚ
DOUBLE_BSLASHÚESCAPED_BSLASHÚstartÚendÚUNESCAPED_PLUSrr=r/rGÚetreeÚElementrrr2rÚ
SubElementÚmd_utilÚ AtomicStringÚtext)rÚdataÚquotedÚcontentr3Úelr5Ú
item_classÚ item_namerrMÚattrrLs r#Ú handleMatchzKeysPattern.handleMatch©ð :Š:Øw‰wqŒzØ—w‘w˜yÓ)×1´ÓPÐRS×RYÑRYÐZ[ÓR\Ð^_×^cÑ^cÐdeÓ^fЈˆGÜ+¨A¯G©G°A«JÓ
:ؘ#“:Ø—~‘~ jÔ !™ ˜Ø—NN 4×#3Ñ#3°CÓ#8Õ
Ø'à89¿¹À»
×8HÑ8HÈÓ8MÖt×ÕNˆ 7‰?Ø
]‰]Ø—kk‰U vØ26·,²,ˆgs—xx § ¡ Ó
.ÀBó
ˆð