pygments-openssl 2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,226 @@
1
+ """Pygments lexer for OpenSSL configuration files
2
+
3
+ With inspiration from IniLexer and BashLexer.
4
+ """
5
+
6
+ from pygments.lexer import Lexer, LexerContext, RegexLexer, ExtendedRegexLexer, \
7
+ bygroups, include, using, this, do_insertions, default
8
+ from pygments.token import Punctuation, Text, Comment, Keyword, Name, String, \
9
+ Generic, Operator, Number, Whitespace, Literal
10
+
11
+ T_LHS = Name.Attribute
12
+ T_RHS = String
13
+
14
+ # Pygments 2.11 changed the whitespace token type
15
+ from pygments import lex, lexers
16
+ T_SPACE = list(lex(' ', lexers.get_lexer_by_name('ini')))[0][0]
17
+
18
+ T_NUMBER = T_RHS
19
+ T_EMAIL = T_RHS
20
+ T_IP = T_RHS
21
+ T_HEX = T_RHS
22
+
23
+ T_KNOWNDIR = Name.Builtin
24
+ T_OTHERDIR = T_LHS
25
+
26
+ T_KNOWNNAME = Keyword.Pseudo
27
+ T_OTHERNAME = T_RHS
28
+
29
+
30
+ class OpenSSLConfLexer(RegexLexer):
31
+ """Pygments lexer for OpenSSL configuration files.
32
+ """
33
+
34
+ name = 'OpenSSL'
35
+ aliases = ['openssl']
36
+ filenames = ['*.cnf', '*.conf']
37
+ mimetypes = ['text/x-openssl']
38
+
39
+ tokens = {
40
+ 'comment': [
41
+ # Comment
42
+ (r'#.*(?=\n)', Comment),
43
+ ],
44
+ 'string': [
45
+ # Double-quoted string
46
+ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
47
+ # Single-quoted string
48
+ (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
49
+ ],
50
+ 'variable': [
51
+ # Variable name inside curly braces
52
+ (r'\${', Name.Variable, 'curly-brace'),
53
+ # Variable name inside parentheses
54
+ (r'\$\(', Name.Variable, 'paren'),
55
+ # Variable name
56
+ (r'\$\w+(?:::\w+)?', Name.Variable),
57
+ ],
58
+ 'number': [
59
+ # Float
60
+ (r'(?<=\W)\d+\.\d+(?=\W)', T_NUMBER),
61
+ # Int
62
+ (r'(?<=\W)\d+(?=\W)', T_NUMBER),
63
+ ],
64
+ 'email': [
65
+ # Email
66
+ (r'[\w\.+-]+\@[\w\.-]+', T_EMAIL),
67
+ default('#pop'),
68
+ ],
69
+ 'ip': [
70
+ # IP4
71
+ (r'[\d\.]+', T_IP),
72
+ # IP6
73
+ (r'[\da-fA-F:\.]+', T_IP),
74
+ default('#pop'),
75
+ ],
76
+ 'hex': [
77
+ # Hex
78
+ (r'[\da-fA-F:]+', T_HEX),
79
+ default('#pop'),
80
+ ],
81
+ 'curly-brace': [
82
+ # Exit condition
83
+ (r'}', Name.Variable, '#pop'),
84
+ # Variable name
85
+ (r'\w+(?:::\w+)?', Name.Variable, 'close-brace'),
86
+ # Whitespace
87
+ (r'\s+', T_SPACE),
88
+ # Catch all
89
+ (r'[^}]+', T_RHS),
90
+ ],
91
+ 'close-brace': [
92
+ # Exit condition
93
+ (r'}', Name.Variable, '#pop:2'),
94
+ # Whitespace
95
+ (r'\s+', T_SPACE),
96
+ # Catch all
97
+ (r'[^}]+', T_RHS),
98
+ ],
99
+ 'paren': [
100
+ # Exit condition
101
+ (r'\)', Name.Variable, '#pop'),
102
+ # Variable name
103
+ (r'\w+(?:::\w+)?', Name.Variable, 'close-paren'),
104
+ # Whitespace
105
+ (r'\s+', T_SPACE),
106
+ # Catch all
107
+ (r'[^)]+', T_RHS),
108
+ ],
109
+ 'close-paren': [
110
+ # Exit condition
111
+ (r'\)', Name.Variable, '#pop:2'),
112
+ # Whitespace
113
+ (r'\s+', T_SPACE),
114
+ # Catch all
115
+ (r'[^)]+', T_RHS),
116
+ ],
117
+ 'lhs-default': [
118
+ # Line continuation
119
+ (r'\\(?=\n)', String.Escape),
120
+ # Whitespace
121
+ (r'\s+', T_SPACE),
122
+ # Catch all
123
+ (r'.', T_LHS),
124
+ ],
125
+ 'rhs-default': [
126
+ # Line continuation
127
+ (r'\\(?=\n)', String.Escape),
128
+ # Whitespace
129
+ (r'\s+', T_SPACE),
130
+ # Catch all
131
+ (r'.', T_RHS),
132
+ ],
133
+ 'root': [
134
+ include('comment'),
135
+ # Section header
136
+ (r'\[.*?\](?=\n)', Keyword),
137
+ # Pragma directive
138
+ (r'(?i)(\.pragma)(?=[\s=\\])([^\S\n]*)(=)([^\S\n]*)',
139
+ bygroups(T_KNOWNDIR, T_SPACE, Operator, T_SPACE), 'pragma'),
140
+ (r'(?i)(\.pragma)(?=[\s\\])([^\S\n]*)',
141
+ bygroups(T_KNOWNDIR, T_SPACE), 'pragma'),
142
+ # Include directive
143
+ (r'(?i)(\.include)(?=[\s=\\])([^\S\n]*)(=)([^\S\n]*)',
144
+ bygroups(T_KNOWNDIR, T_SPACE, Operator, T_SPACE), 'other'),
145
+ (r'(?i)(\.include)(?=[\s\\])([^\S\n]*)',
146
+ bygroups(T_KNOWNDIR, T_SPACE), 'other'),
147
+ # Other directives
148
+ (r'(\.[\w-]+)([^\S\n]*)(=)([^\S\n]*)',
149
+ bygroups(T_OTHERDIR, T_SPACE, Operator, T_SPACE), 'other'),
150
+ (r'(\.[\w-]+)([^\S\n]*)',
151
+ bygroups(T_OTHERDIR, T_SPACE), 'other'),
152
+ # Left hand side
153
+ (r'([\w\.;-]+)(\s*)', bygroups(T_LHS, T_SPACE)),
154
+ # Operator
155
+ (r'(=)([^\S\n]*)', bygroups(Operator, T_SPACE), 'rhs'),
156
+ include('lhs-default'),
157
+ ],
158
+ 'rhs': [
159
+ include('comment'),
160
+ # Exit condition
161
+ (r'(?<!\\)\n', T_SPACE, '#pop'),
162
+ # Email
163
+ (r'(?i)(?<=\W)(email)(?=\W)([^\S\n]*)(:)([^\S\n]*)',
164
+ bygroups(T_RHS, T_SPACE, T_RHS, T_SPACE), 'email'),
165
+ # IP
166
+ (r'(?i)(?<=\W)(IP)(?=\W)([^\S\n]*)(:)([^\S\n]*)',
167
+ bygroups(T_RHS, T_SPACE, T_RHS, T_SPACE), 'ip'),
168
+ # DER
169
+ (r'(?i)(?<=\W)(DER)(?=\W)([^\S\n]*)(:)([^\S\n]*)',
170
+ bygroups(T_RHS, T_SPACE, T_RHS, T_SPACE), 'hex'),
171
+ include('string'),
172
+ include('variable'),
173
+ # OID
174
+ (r'(?<=\W)\d+\.(?:\d+\.?)*(?=\W)', Name.Function),
175
+ include('number'),
176
+ # Section reference
177
+ (r'(?<=\W)\@\w+', Name.Constant),
178
+ # Critical keyword
179
+ (r'(?i)(?<=\W)critical(?=\W)', Keyword.Pseudo),
180
+ include('rhs-default'),
181
+ ],
182
+ 'pragma': [
183
+ include('comment'),
184
+ # Exit condition
185
+ (r'(?<!\\)\n', T_SPACE, '#pop'),
186
+ # Known directive names
187
+ (r'(?i)(?<=\W)(abspath|dollarid|includedir)(?=\W)([^\S\n]*)(:)([^\S\n]*)',
188
+ bygroups(T_KNOWNNAME, T_SPACE, Operator, T_SPACE), 'value'),
189
+ # Other directive names
190
+ (r'([\w-]+)([^\S\n]*)(:)([^\S\n]*)',
191
+ bygroups(T_OTHERNAME, T_SPACE, T_RHS, T_SPACE), 'value'),
192
+ include('string'),
193
+ include('variable'),
194
+ include('number'),
195
+ include('rhs-default'),
196
+ ],
197
+ 'other': [
198
+ include('comment'),
199
+ # Exit condition
200
+ (r'(?<!\\)\n', T_SPACE, '#pop'),
201
+ include('string'),
202
+ include('variable'),
203
+ include('number'),
204
+ include('rhs-default'),
205
+ ],
206
+ 'value': [
207
+ include('comment'),
208
+ # Exit condition
209
+ (r'(?<!\\)\n', T_SPACE, '#pop:2'),
210
+ include('string'),
211
+ include('variable'),
212
+ include('number'),
213
+ include('rhs-default'),
214
+ ],
215
+ }
216
+
217
+ def __init__(self, **options):
218
+ super(OpenSSLConfLexer, self).__init__(**options)
219
+ # Always apply tokenmerge filter
220
+ self.add_filter('tokenmerge')
221
+
222
+ def analyse_text(text):
223
+ npos = text.find('\n')
224
+ if npos < 3:
225
+ return False
226
+ return text[0] == '[' and text[npos-1] == ']'
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.4
2
+ Name: pygments-openssl
3
+ Version: 2.0
4
+ Summary: Syntax coloring for OpenSSL configuration files
5
+ Home-page: https://github.com/stefanholek/pygments-openssl
6
+ Author: Stefan H. Holek
7
+ Author-email: stefan@epy.co.at
8
+ License: BSD-2-Clause
9
+ Keywords: sphinx,pygments,lexer,openssl,openssl.cnf,openssl.conf,syntax,coloring,colors,highlight
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Plugins
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Topic :: Text Processing :: Filters
19
+ Requires-Python: >=3.5
20
+ Description-Content-Type: text/x-rst
21
+ License-File: LICENSE
22
+ Requires-Dist: pygments
23
+ Dynamic: license-file
24
+
25
+ ================
26
+ pygments-openssl
27
+ ================
28
+ ------------------------------------------------
29
+ Syntax coloring for OpenSSL configuration files
30
+ ------------------------------------------------
31
+
32
+ Overview
33
+ ========
34
+
35
+ This package provides a Pygments_ lexer for OpenSSL_ configuration files.
36
+ The lexer is published as an entry point and Pygments will pick it up
37
+ automatically.
38
+
39
+ You can use the ``openssl`` language with Pygments::
40
+
41
+ $ pygmentize -l openssl /etc/openssl/openssl.cnf
42
+
43
+ In Sphinx_ documents the lexer is selected with the ``highlight`` directive::
44
+
45
+ .. highlight:: openssl
46
+
47
+ .. _OpenSSL: https://www.openssl.org/docs/manmaster/man5/config.html
48
+ .. _Pygments: https://pygments.org/
49
+ .. _Sphinx: https://sphinx-doc.org/
50
+
51
+ Installation
52
+ ============
53
+
54
+ Use your favorite installer to install pygments-openssl into the same
55
+ Python environment you have installed Pygments. For example::
56
+
57
+ $ pip install pygments-openssl
58
+
59
+ To verify the installation run::
60
+
61
+ $ pygmentize -L lexer | grep -i openssl
62
+ * openssl:
63
+ OpenSSL (filenames *.cnf, *.conf)
64
+
65
+
66
+ Changelog
67
+ =========
68
+
69
+ 2.0 - 2026-07-07
70
+ ----------------
71
+
72
+ * Update INI lexer tests for Pygments >= 2.19.
73
+ [stefan]
74
+
75
+ * Remove support for universal wheels.
76
+ [stefan]
77
+
78
+ * Remove deprecated license classifier.
79
+ [stefan]
80
+
81
+ * Upgrade GitHub workflow.
82
+ [stefan]
83
+
84
+ * Require Python >= 3.5.
85
+ [stefan]
86
+
87
+ 1.6 - 2023-09-14
88
+ ----------------
89
+
90
+ * Update INI lexer tests for Pygments >= 2.14.
91
+ [stefan]
92
+
93
+ * Update tox.ini for latest tox.
94
+ [stefan]
95
+
96
+ * Add GitHub CI workflow.
97
+ [stefan]
98
+
99
+ 1.5 - 2022-02-27
100
+ ----------------
101
+
102
+ * Add Python 3.8-3.10 to tox.ini. Remove old Python versions.
103
+ [stefan]
104
+
105
+ * Replace deprecated ``python setup.py test`` in tox.ini.
106
+ [stefan]
107
+
108
+ * Remove deprecated ``test_suite`` from setup.py.
109
+ [stefan]
110
+
111
+ * Move lexer into ``pygments_openssl`` namespace.
112
+ [stefan]
113
+
114
+ * Move metadata to setup.cfg and add a pyproject.toml file.
115
+ [stefan]
116
+
117
+ * Include tests in sdist but not in wheel.
118
+ [stefan]
119
+
120
+ * Support new ``.pragma`` and ``.include`` directives.
121
+ [stefan]
122
+
123
+ * Pygments 2.11 whitespace token modernization.
124
+ [stefan]
125
+
126
+ 1.4 - 2019-01-25
127
+ ----------------
128
+
129
+ * Add MANIFEST.in.
130
+ [stefan]
131
+
132
+ * Release as wheel.
133
+ [stefan]
134
+
135
+ 1.3 - 2017-02-05
136
+ ----------------
137
+
138
+ * Add a LICENSE file.
139
+ [stefan]
140
+
141
+ * Add a test suite and fix two minor whitespace lexing issues.
142
+ [stefan]
143
+
144
+ 1.2 - 2013-11-21
145
+ ----------------
146
+
147
+ * Update documentation.
148
+ [stefan]
149
+
150
+ 1.1 - 2012-10-12
151
+ ----------------
152
+
153
+ * Detect and color line continuations.
154
+ [stefan]
155
+
156
+ 1.0 - 2012-10-10
157
+ ----------------
158
+
159
+ * Initial release.
160
+ [stefan]
@@ -0,0 +1,8 @@
1
+ pygments_openssl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pygments_openssl/lexer.py,sha256=FNhfXWCQbwE8UO_bedGd96mW1HW5yhpX_WzEC0frRgs,7271
3
+ pygments_openssl-2.0.dist-info/licenses/LICENSE,sha256=HcTMhQ7-VWA03Chfpg1AY7PnCqu0jgsVwiLmiHQT7Q0,1288
4
+ pygments_openssl-2.0.dist-info/METADATA,sha256=FBppa7mvXw8PvRRjpRdJEwRTTnE7eUI-4rHjFZtlNJg,3464
5
+ pygments_openssl-2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ pygments_openssl-2.0.dist-info/entry_points.txt,sha256=cEpx1R2ElpSUK-JUT3puIH_NRZJudhAXWOlVm3RDGiw,68
7
+ pygments_openssl-2.0.dist-info/top_level.txt,sha256=wR1gmQGFVoedffk4giMi4EpOrrXexYFETwOYYOWiyS8,17
8
+ pygments_openssl-2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [pygments.lexers]
2
+ openssl = pygments_openssl.lexer:OpenSSLConfLexer
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2012-2026 Stefan H. Holek
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
+ SUCH DAMAGE.
@@ -0,0 +1 @@
1
+ pygments_openssl