summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/pygments/lexers/asc.py
diff options
context:
space:
mode:
authorcyfraeviolae <cyfraeviolae>2024-04-03 03:10:44 -0400
committercyfraeviolae <cyfraeviolae>2024-04-03 03:10:44 -0400
commit6d7ba58f880be618ade07f8ea080fe8c4bf8a896 (patch)
treeb1c931051ffcebd2bd9d61d98d6233ffa289bbce /venv/lib/python3.11/site-packages/pygments/lexers/asc.py
parent4f884c9abc32990b4061a1bb6997b4b37e58ea0b (diff)
venv
Diffstat (limited to 'venv/lib/python3.11/site-packages/pygments/lexers/asc.py')
-rw-r--r--venv/lib/python3.11/site-packages/pygments/lexers/asc.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/venv/lib/python3.11/site-packages/pygments/lexers/asc.py b/venv/lib/python3.11/site-packages/pygments/lexers/asc.py
new file mode 100644
index 0000000..e261f41
--- /dev/null
+++ b/venv/lib/python3.11/site-packages/pygments/lexers/asc.py
@@ -0,0 +1,55 @@
+"""
+ pygments.lexers.asc
+ ~~~~~~~~~~~~~~~~~~~
+
+ Lexer for various ASCII armored files.
+
+ :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+import re
+
+from pygments.lexer import RegexLexer, bygroups
+from pygments.token import Comment, Generic, Name, Operator, String, Whitespace
+
+__all__ = ['AscLexer']
+
+
+class AscLexer(RegexLexer):
+ """
+ Lexer for ASCII armored files, containing `-----BEGIN/END ...-----` wrapped
+ base64 data.
+
+ .. versionadded:: 2.10
+ """
+ name = 'ASCII armored'
+ aliases = ['asc', 'pem']
+ filenames = [
+ '*.asc', # PGP; *.gpg, *.pgp, and *.sig too, but those can be binary
+ '*.pem', # X.509; *.cer, *.crt, *.csr, and key etc too, but those can be binary
+ 'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk',
+ 'id_rsa', # SSH private keys
+ ]
+ mimetypes = ['application/pgp-keys', 'application/pgp-encrypted',
+ 'application/pgp-signature', 'application/pem-certificate-chain']
+
+ flags = re.MULTILINE
+
+ tokens = {
+ 'root': [
+ (r'\s+', Whitespace),
+ (r'^-----BEGIN [^\n]+-----$', Generic.Heading, 'data'),
+ (r'\S+', Comment),
+ ],
+ 'data': [
+ (r'\s+', Whitespace),
+ (r'^([^:]+)(:)([ \t]+)(.*)',
+ bygroups(Name.Attribute, Operator, Whitespace, String)),
+ (r'^-----END [^\n]+-----$', Generic.Heading, 'root'),
+ (r'\S+', String),
+ ],
+ }
+
+ def analyse_text(text):
+ if re.search(r'^-----BEGIN [^\n]+-----\r?\n', text):
+ return True