Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison pygments_lexer_pseudocode2/uniprops.py @ 105:cec52d83869a
Handle much more characters from the Unicode codeset in expressions.
While there: FIX: Add forgotten Punctuation characters `?' and `@'.
While there: Allow the escaping of single and double quotes that normally
start a string (e.g. for expressions like f' is the first derivation of f).
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 04 May 2026 16:30:36 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 104:ffe6ea2cf69b | 105:cec52d83869a |
|---|---|
| 1 # -*- coding: utf-8 -*- | |
| 2 # :- | |
| 3 # SPDX-FileCopyrightText: © 2026 Franz Glasner | |
| 4 # SPDX-License-Identifier: MIT | |
| 5 # :- | |
| 6 r"""A somewhat changed variant of :mod:`pygments.unistring`. | |
| 7 | |
| 8 We handle ASCII characters mostly ourself. | |
| 9 | |
| 10 """ | |
| 11 | |
| 12 __all__ = [] | |
| 13 | |
| 14 | |
| 15 import pygments.unistring | |
| 16 | |
| 17 | |
| 18 def _remove_ascii(s): | |
| 19 """Remove the characters in the ASCII range from `s` and return the | |
| 20 adjusted string. | |
| 21 | |
| 22 Assumes that in `s` the ASCII chars are sorted before the Unicode | |
| 23 codepoints as in :mod:`pygments.unistring`. | |
| 24 | |
| 25 """ | |
| 26 idx = 0 | |
| 27 while ord(s[idx]) < 0x80: | |
| 28 idx += 1 | |
| 29 if idx > 0: | |
| 30 return s[idx:] | |
| 31 else: | |
| 32 # nothing changed | |
| 33 return s | |
| 34 | |
| 35 | |
| 36 Pc = _remove_ascii(pygments.unistring.Pc) | |
| 37 Pd = _remove_ascii(pygments.unistring.Pd) | |
| 38 Pe = _remove_ascii(pygments.unistring.Pe) | |
| 39 Ps = _remove_ascii(pygments.unistring.Ps) | |
| 40 Pi = _remove_ascii(pygments.unistring.Pi) | |
| 41 Pf = _remove_ascii(pygments.unistring.Pf) | |
| 42 Po = _remove_ascii(pygments.unistring.Po) | |
| 43 Sc = _remove_ascii(pygments.unistring.Sc) | |
| 44 So = _remove_ascii(pygments.unistring.So) | |
| 45 Sm = _remove_ascii(pygments.unistring.Sm) | |
| 46 Zl = _remove_ascii(pygments.unistring.Zl) | |
| 47 Zp = _remove_ascii(pygments.unistring.Zp) | |
| 48 Zs = _remove_ascii(pygments.unistring.Zs) |
