pygments.rb 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/CHANGELOG.adoc +5 -0
  4. data/bench.rb +2 -2
  5. data/lib/pygments/lexer.rb +1 -1
  6. data/lib/pygments/mentos.py +6 -4
  7. data/lib/pygments/popen.rb +14 -7
  8. data/lib/pygments/version.rb +1 -1
  9. data/lib/pygments.rb +8 -2
  10. data/pygments.rb.gemspec +4 -4
  11. data/test/test_pygments.rb +13 -7
  12. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/AUTHORS +8 -1
  13. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/INSTALLER +0 -0
  14. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/LICENSE +0 -0
  15. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/METADATA +1 -1
  16. data/vendor/pygments-main/Pygments-2.10.0.dist-info/RECORD +524 -0
  17. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/REQUESTED +0 -0
  18. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/WHEEL +0 -0
  19. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/entry_points.txt +0 -0
  20. data/vendor/pygments-main/{Pygments-2.8.1.dist-info → Pygments-2.10.0.dist-info}/top_level.txt +0 -0
  21. data/vendor/pygments-main/bin/pygmentize +1 -1
  22. data/vendor/pygments-main/pygments/__init__.py +1 -1
  23. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -0
  24. data/vendor/pygments-main/pygments/formatters/html.py +20 -7
  25. data/vendor/pygments-main/pygments/formatters/pangomarkup.py +83 -0
  26. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +55 -14
  27. data/vendor/pygments-main/pygments/lexers/_julia_builtins.py +401 -0
  28. data/vendor/pygments-main/pygments/lexers/_mapping.py +68 -52
  29. data/vendor/pygments-main/pygments/lexers/actionscript.py +2 -2
  30. data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
  31. data/vendor/pygments-main/pygments/lexers/amdgpu.py +9 -4
  32. data/vendor/pygments-main/pygments/lexers/apdlexer.py +448 -0
  33. data/vendor/pygments-main/pygments/lexers/apl.py +6 -3
  34. data/vendor/pygments-main/pygments/lexers/asc.py +51 -0
  35. data/vendor/pygments-main/pygments/lexers/asm.py +86 -58
  36. data/vendor/pygments-main/pygments/lexers/automation.py +1 -1
  37. data/vendor/pygments-main/pygments/lexers/bibtex.py +2 -2
  38. data/vendor/pygments-main/pygments/lexers/c_cpp.py +60 -33
  39. data/vendor/pygments-main/pygments/lexers/c_like.py +102 -3
  40. data/vendor/pygments-main/pygments/lexers/cddl.py +2 -2
  41. data/vendor/pygments-main/pygments/lexers/chapel.py +53 -29
  42. data/vendor/pygments-main/pygments/lexers/clean.py +6 -6
  43. data/vendor/pygments-main/pygments/lexers/configs.py +133 -43
  44. data/vendor/pygments-main/pygments/lexers/csound.py +2 -2
  45. data/vendor/pygments-main/pygments/lexers/devicetree.py +1 -1
  46. data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
  47. data/vendor/pygments-main/pygments/lexers/erlang.py +1 -1
  48. data/vendor/pygments-main/pygments/lexers/floscript.py +1 -1
  49. data/vendor/pygments-main/pygments/lexers/futhark.py +5 -4
  50. data/vendor/pygments-main/pygments/lexers/gcodelexer.py +36 -0
  51. data/vendor/pygments-main/pygments/lexers/go.py +1 -1
  52. data/vendor/pygments-main/pygments/lexers/graphics.py +1 -1
  53. data/vendor/pygments-main/pygments/lexers/graphviz.py +5 -4
  54. data/vendor/pygments-main/pygments/lexers/gsql.py +92 -0
  55. data/vendor/pygments-main/pygments/lexers/haskell.py +4 -4
  56. data/vendor/pygments-main/pygments/lexers/haxe.py +1 -1
  57. data/vendor/pygments-main/pygments/lexers/installers.py +2 -2
  58. data/vendor/pygments-main/pygments/lexers/javascript.py +145 -127
  59. data/vendor/pygments-main/pygments/lexers/jslt.py +94 -0
  60. data/vendor/pygments-main/pygments/lexers/julia.py +135 -183
  61. data/vendor/pygments-main/pygments/lexers/jvm.py +262 -202
  62. data/vendor/pygments-main/pygments/lexers/kuin.py +299 -0
  63. data/vendor/pygments-main/pygments/lexers/lisp.py +18 -15
  64. data/vendor/pygments-main/pygments/lexers/markup.py +3 -3
  65. data/vendor/pygments-main/pygments/lexers/matlab.py +23 -10
  66. data/vendor/pygments-main/pygments/lexers/meson.py +155 -0
  67. data/vendor/pygments-main/pygments/lexers/mime.py +6 -21
  68. data/vendor/pygments-main/pygments/lexers/ml.py +1 -1
  69. data/vendor/pygments-main/pygments/lexers/nimrod.py +1 -1
  70. data/vendor/pygments-main/pygments/lexers/objective.py +3 -3
  71. data/vendor/pygments-main/pygments/lexers/parsers.py +1 -1
  72. data/vendor/pygments-main/pygments/lexers/procfile.py +43 -0
  73. data/vendor/pygments-main/pygments/lexers/promql.py +1 -1
  74. data/vendor/pygments-main/pygments/lexers/python.py +19 -5
  75. data/vendor/pygments-main/pygments/lexers/resource.py +1 -1
  76. data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
  77. data/vendor/pygments-main/pygments/lexers/ruby.py +1 -1
  78. data/vendor/pygments-main/pygments/lexers/rust.py +9 -10
  79. data/vendor/pygments-main/pygments/lexers/scripting.py +7 -7
  80. data/vendor/pygments-main/pygments/lexers/shell.py +11 -8
  81. data/vendor/pygments-main/pygments/lexers/smithy.py +79 -0
  82. data/vendor/pygments-main/pygments/lexers/smv.py +1 -1
  83. data/vendor/pygments-main/pygments/lexers/special.py +15 -2
  84. data/vendor/pygments-main/pygments/lexers/supercollider.py +1 -1
  85. data/vendor/pygments-main/pygments/lexers/tcl.py +3 -3
  86. data/vendor/pygments-main/pygments/lexers/teal.py +88 -0
  87. data/vendor/pygments-main/pygments/lexers/templates.py +19 -19
  88. data/vendor/pygments-main/pygments/lexers/teraterm.py +1 -1
  89. data/vendor/pygments-main/pygments/lexers/testing.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/theorem.py +4 -2
  91. data/vendor/pygments-main/pygments/lexers/thingsdb.py +118 -0
  92. data/vendor/pygments-main/pygments/lexers/tnt.py +25 -15
  93. data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
  94. data/vendor/pygments-main/pygments/lexers/webassembly.py +120 -0
  95. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  96. data/vendor/pygments-main/pygments/style.py +1 -1
  97. data/vendor/pygments-main/pygments/styles/__init__.py +2 -0
  98. data/vendor/pygments-main/pygments/styles/friendly.py +1 -0
  99. data/vendor/pygments-main/pygments/styles/gruvbox.py +107 -0
  100. data/vendor/pygments-main/pygments/styles/native.py +1 -0
  101. metadata +29 -14
  102. data/vendor/pygments-main/Pygments-2.8.1.dist-info/RECORD +0 -494
@@ -575,7 +575,7 @@ class LiterateHaskellLexer(LiterateLexer):
575
575
  .. versionadded:: 0.9
576
576
  """
577
577
  name = 'Literate Haskell'
578
- aliases = ['lhs', 'literate-haskell', 'lhaskell']
578
+ aliases = ['literate-haskell', 'lhaskell', 'lhs']
579
579
  filenames = ['*.lhs']
580
580
  mimetypes = ['text/x-literate-haskell']
581
581
 
@@ -598,7 +598,7 @@ class LiterateIdrisLexer(LiterateLexer):
598
598
  .. versionadded:: 2.0
599
599
  """
600
600
  name = 'Literate Idris'
601
- aliases = ['lidr', 'literate-idris', 'lidris']
601
+ aliases = ['literate-idris', 'lidris', 'lidr']
602
602
  filenames = ['*.lidr']
603
603
  mimetypes = ['text/x-literate-idris']
604
604
 
@@ -621,7 +621,7 @@ class LiterateAgdaLexer(LiterateLexer):
621
621
  .. versionadded:: 2.0
622
622
  """
623
623
  name = 'Literate Agda'
624
- aliases = ['lagda', 'literate-agda']
624
+ aliases = ['literate-agda', 'lagda']
625
625
  filenames = ['*.lagda']
626
626
  mimetypes = ['text/x-literate-agda']
627
627
 
@@ -644,7 +644,7 @@ class LiterateCryptolLexer(LiterateLexer):
644
644
  .. versionadded:: 2.0
645
645
  """
646
646
  name = 'Literate Cryptol'
647
- aliases = ['lcry', 'literate-cryptol', 'lcryptol']
647
+ aliases = ['literate-cryptol', 'lcryptol', 'lcry']
648
648
  filenames = ['*.lcry']
649
649
  mimetypes = ['text/x-literate-cryptol']
650
650
 
@@ -26,7 +26,7 @@ class HaxeLexer(ExtendedRegexLexer):
26
26
  """
27
27
 
28
28
  name = 'Haxe'
29
- aliases = ['hx', 'haxe', 'hxsl']
29
+ aliases = ['haxe', 'hxsl', 'hx']
30
30
  filenames = ['*.hx', '*.hxsl']
31
31
  mimetypes = ['text/haxe', 'text/x-haxe', 'text/x-hx']
32
32
 
@@ -223,7 +223,7 @@ class SourcesListLexer(RegexLexer):
223
223
  """
224
224
 
225
225
  name = 'Debian Sourcelist'
226
- aliases = ['sourceslist', 'sources.list', 'debsources']
226
+ aliases = ['debsources', 'sourceslist', 'sources.list']
227
227
  filenames = ['sources.list']
228
228
  mimetype = ['application/x-debian-sourceslist']
229
229
 
@@ -270,7 +270,7 @@ class DebianControlLexer(RegexLexer):
270
270
  .. versionadded:: 0.9
271
271
  """
272
272
  name = 'Debian Control file'
273
- aliases = ['control', 'debcontrol']
273
+ aliases = ['debcontrol', 'control']
274
274
  filenames = ['control']
275
275
 
276
276
  tokens = {
@@ -10,16 +10,17 @@
10
10
 
11
11
  import re
12
12
 
13
- from pygments.lexer import RegexLexer, include, bygroups, default, using, \
14
- this, words, combined
13
+ from pygments.lexer import bygroups, combined, default, do_insertions, include, \
14
+ inherit, Lexer, RegexLexer, this, using, words
15
15
  from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
16
- Number, Punctuation, Other
16
+ Number, Punctuation, Other, Generic
17
17
  from pygments.util import get_bool_opt
18
18
  import pygments.unistring as uni
19
19
 
20
20
  __all__ = ['JavascriptLexer', 'KalLexer', 'LiveScriptLexer', 'DartLexer',
21
21
  'TypeScriptLexer', 'LassoLexer', 'ObjectiveJLexer',
22
- 'CoffeeScriptLexer', 'MaskLexer', 'EarlGreyLexer', 'JuttleLexer']
22
+ 'CoffeeScriptLexer', 'MaskLexer', 'EarlGreyLexer', 'JuttleLexer',
23
+ 'NodeConsoleLexer']
23
24
 
24
25
  JS_IDENT_START = ('(?:[$_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') +
25
26
  ']|\\\\u[a-fA-F0-9]{4})')
@@ -28,6 +29,7 @@ JS_IDENT_PART = ('(?:[$' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
28
29
  '\u200c\u200d]|\\\\u[a-fA-F0-9]{4})')
29
30
  JS_IDENT = JS_IDENT_START + '(?:' + JS_IDENT_PART + ')*'
30
31
 
32
+ line_re = re.compile('.*?\n')
31
33
 
32
34
  class JavascriptLexer(RegexLexer):
33
35
  """
@@ -35,8 +37,8 @@ class JavascriptLexer(RegexLexer):
35
37
  """
36
38
 
37
39
  name = 'JavaScript'
38
- aliases = ['js', 'javascript']
39
- filenames = ['*.js', '*.jsm', '*.mjs']
40
+ aliases = ['javascript', 'js']
41
+ filenames = ['*.js', '*.jsm', '*.mjs', '*.cjs']
40
42
  mimetypes = ['application/javascript', 'application/x-javascript',
41
43
  'text/x-javascript', 'text/javascript']
42
44
 
@@ -52,7 +54,7 @@ class JavascriptLexer(RegexLexer):
52
54
  'slashstartsregex': [
53
55
  include('commentsandwhitespace'),
54
56
  (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
55
- r'([gimuys]+\b|\B)', String.Regex, '#pop'),
57
+ r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
56
58
  (r'(?=/)', Text, ('#pop', 'badregex')),
57
59
  default('#pop')
58
60
  ],
@@ -75,23 +77,43 @@ class JavascriptLexer(RegexLexer):
75
77
  (r'(\.[0-9]+|[0-9]+\.[0-9]*|[0-9]+)([eE][-+]?[0-9]+)?', Number.Float),
76
78
 
77
79
  (r'\.\.\.|=>', Punctuation),
78
- (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
79
- r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
80
+ (r'\+\+|--|~|\?\?=?|\?|:|\\(?=\n)|'
81
+ r'(<<|>>>?|==?|!=?|(?:\*\*|\|\||&&|[-<>+*%&|^/]))=?', Operator, 'slashstartsregex'),
80
82
  (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
81
83
  (r'[})\].]', Punctuation),
84
+
85
+ (r'(typeof|instanceof|in|void|delete|new)\b', Operator.Word, 'slashstartsregex'),
86
+
87
+ # Match stuff like: constructor
88
+ (r'\b(constructor|from|as)\b', Keyword.Reserved),
89
+
82
90
  (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
83
- r'throw|try|catch|finally|new|delete|typeof|instanceof|void|yield|await|async|'
84
- r'this|of|static|export|import|debugger|extends|super)\b', Keyword, 'slashstartsregex'),
91
+ r'throw|try|catch|finally|yield|await|async|this|of|static|export|'
92
+ r'import|debugger|extends|super)\b', Keyword, 'slashstartsregex'),
85
93
  (r'(var|let|const|with|function|class)\b', Keyword.Declaration, 'slashstartsregex'),
86
- (r'(abstract|boolean|byte|char|double|enum|final|float|goto'
87
- r'implements|int|interface|long|native|package|private|protected'
94
+
95
+ (r'(abstract|boolean|byte|char|double|enum|final|float|goto|'
96
+ r'implements|int|interface|long|native|package|private|protected|'
88
97
  r'public|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
89
98
  (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
90
- (r'(Array|Boolean|Date|BigInt|Error|Function|Math|'
99
+
100
+ (r'(Array|Boolean|Date|BigInt|Function|Math|ArrayBuffer|'
91
101
  r'Number|Object|RegExp|String|Promise|Proxy|decodeURI|'
92
102
  r'decodeURIComponent|encodeURI|encodeURIComponent|'
93
- r'Error|eval|isFinite|isNaN|isSafeInteger|parseFloat|parseInt|'
94
- r'document|this|window|globalThis|Symbol)\b', Name.Builtin),
103
+ r'eval|isFinite|isNaN|parseFloat|parseInt|DataView|'
104
+ r'document|window|globalThis|global|Symbol|Intl|'
105
+ r'WeakSet|WeakMap|Set|Map|Reflect|JSON|Atomics|'
106
+ r'Int(?:8|16|32)Array|BigInt64Array|Float32Array|Float64Array|'
107
+ r'Uint8ClampedArray|Uint(?:8|16|32)Array|BigUint64Array)\b', Name.Builtin),
108
+
109
+ (r'((?:Eval|Internal|Range|Reference|Syntax|Type|URI)?Error)\b', Name.Exception),
110
+
111
+ # Match stuff like: super(argument, list)
112
+ (r'(super)(\s*)(\([\w,?.$\s]+\s*\))',
113
+ bygroups(Keyword, Text), 'slashstartsregex'),
114
+ # Match stuff like: function() {...}
115
+ (r'([a-zA-Z_?.$][\w?.$]*)(?=\(\) \{)', Name.Other, 'slashstartsregex'),
116
+
95
117
  (JS_IDENT, Name.Other),
96
118
  (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
97
119
  (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
@@ -112,6 +134,43 @@ class JavascriptLexer(RegexLexer):
112
134
  }
113
135
 
114
136
 
137
+ class TypeScriptLexer(JavascriptLexer):
138
+ """
139
+ For `TypeScript <http://typescriptlang.org/>`_ source code.
140
+
141
+ .. versionadded:: 1.6
142
+ """
143
+
144
+ name = 'TypeScript'
145
+ aliases = ['typescript', 'ts']
146
+ filenames = ['*.ts']
147
+ mimetypes = ['application/x-typescript', 'text/x-typescript']
148
+
149
+ # Higher priority than the TypoScriptLexer, as TypeScript is far more
150
+ # common these days
151
+ priority = 0.5
152
+
153
+ tokens = {
154
+ 'root': [
155
+ (r'(abstract|implements|private|protected|public|readonly)\b',
156
+ Keyword, 'slashstartsregex'),
157
+ (r'(enum|interface|override)\b', Keyword.Declaration, 'slashstartsregex'),
158
+ (r'\b(declare|type)\b', Keyword.Reserved),
159
+ # Match variable type keywords
160
+ (r'\b(string|boolean|number)\b', Keyword.Type),
161
+ # Match stuff like: module name {...}
162
+ (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)',
163
+ bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
164
+ # Match stuff like: (function: return type)
165
+ (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)',
166
+ bygroups(Name.Other, Text, Keyword.Type)),
167
+ # Match stuff like: Decorators
168
+ (r'@' + JS_IDENT, Keyword.Declaration),
169
+ inherit,
170
+ ],
171
+ }
172
+
173
+
115
174
  class KalLexer(RegexLexer):
116
175
  """
117
176
  For `Kal`_ source code.
@@ -157,7 +216,7 @@ class KalLexer(RegexLexer):
157
216
  'root': [
158
217
  include('commentsandwhitespace'),
159
218
  (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
160
- r'([gimuys]+\b|\B)', String.Regex),
219
+ r'([gimuysd]+\b|\B)', String.Regex),
161
220
  (r'\?|:|_(?=\n)|==?|!=|-(?!>)|[<>+*/-]=?',
162
221
  Operator),
163
222
  (r'\b(and|or|isnt|is|not|but|bitwise|mod|\^|xor|exists|'
@@ -231,13 +290,13 @@ class LiveScriptLexer(RegexLexer):
231
290
  """
232
291
  For `LiveScript`_ source code.
233
292
 
234
- .. _LiveScript: http://gkz.github.com/LiveScript/
293
+ .. _LiveScript: https://livescript.net/
235
294
 
236
295
  .. versionadded:: 1.6
237
296
  """
238
297
 
239
298
  name = 'LiveScript'
240
- aliases = ['live-script', 'livescript']
299
+ aliases = ['livescript', 'live-script']
241
300
  filenames = ['*.ls']
242
301
  mimetypes = ['text/livescript']
243
302
 
@@ -250,7 +309,7 @@ class LiveScriptLexer(RegexLexer):
250
309
  ],
251
310
  'multilineregex': [
252
311
  include('commentsandwhitespace'),
253
- (r'//([gimuys]+\b|\B)', String.Regex, '#pop'),
312
+ (r'//([gimuysd]+\b|\B)', String.Regex, '#pop'),
254
313
  (r'/', String.Regex),
255
314
  (r'[^/#]+', String.Regex)
256
315
  ],
@@ -258,7 +317,7 @@ class LiveScriptLexer(RegexLexer):
258
317
  include('commentsandwhitespace'),
259
318
  (r'//', String.Regex, ('#pop', 'multilineregex')),
260
319
  (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
261
- r'([gimuys]+\b|\B)', String.Regex, '#pop'),
320
+ r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
262
321
  (r'/', Operator, '#pop'),
263
322
  default('#pop'),
264
323
  ],
@@ -441,108 +500,6 @@ class DartLexer(RegexLexer):
441
500
  }
442
501
 
443
502
 
444
- class TypeScriptLexer(RegexLexer):
445
- """
446
- For `TypeScript <http://typescriptlang.org/>`_ source code.
447
-
448
- .. versionadded:: 1.6
449
- """
450
-
451
- name = 'TypeScript'
452
- aliases = ['ts', 'typescript']
453
- filenames = ['*.ts', '*.tsx']
454
- mimetypes = ['text/x-typescript']
455
-
456
- flags = re.DOTALL | re.MULTILINE
457
-
458
- # Higher priority than the TypoScriptLexer, as TypeScript is far more
459
- # common these days
460
- priority = 0.5
461
-
462
- tokens = {
463
- 'commentsandwhitespace': [
464
- (r'\s+', Text),
465
- (r'<!--', Comment),
466
- (r'//.*?\n', Comment.Single),
467
- (r'/\*.*?\*/', Comment.Multiline)
468
- ],
469
- 'slashstartsregex': [
470
- include('commentsandwhitespace'),
471
- (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
472
- r'([gimuys]+\b|\B)', String.Regex, '#pop'),
473
- (r'(?=/)', Text, ('#pop', 'badregex')),
474
- default('#pop')
475
- ],
476
- 'badregex': [
477
- (r'\n', Text, '#pop')
478
- ],
479
- 'root': [
480
- (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
481
- include('commentsandwhitespace'),
482
- (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
483
- r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
484
- (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
485
- (r'[})\].]', Punctuation),
486
- (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
487
- r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|'
488
- r'this|async|await|debugger|yield|abstract|static|import|export|'
489
- r'implements|super|extends|private|protected|public|readonly)\b',
490
- Keyword, 'slashstartsregex'),
491
- (r'(var|let|const|with|function|class|type|enum|interface)\b',
492
- Keyword.Declaration, 'slashstartsregex'),
493
- (r'(boolean|byte|char|double|final|float|goto|int|long|native|'
494
- r'package|short|synchronized|throws|transient|volatile)\b', Keyword.Reserved),
495
- (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
496
- (r'(Array|Boolean|Date|Error|Function|Math|'
497
- r'Number|Object|RegExp|String|decodeURI|'
498
- r'decodeURIComponent|encodeURI|encodeURIComponent|'
499
- r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
500
- r'window|globalThis|Symbol|BigInt)\b', Name.Builtin),
501
- # Match stuff like: module name {...}
502
- (r'\b(module)(\s*)(\s*[\w?.$][\w?.$]*)(\s*)',
503
- bygroups(Keyword.Reserved, Text, Name.Other, Text), 'slashstartsregex'),
504
- # Match variable type keywords
505
- (r'\b(string|bool|number)\b', Keyword.Type),
506
- # Match stuff like: constructor
507
- (r'\b(constructor|declare|interface|as|AS)\b', Keyword.Reserved),
508
- # Match stuff like: super(argument, list)
509
- (r'(super)(\s*)(\([\w,?.$\s]+\s*\))',
510
- bygroups(Keyword.Reserved, Text), 'slashstartsregex'),
511
- # Match stuff like: function() {...}
512
- (r'([a-zA-Z_?.$][\w?.$]*)(?=\(\) \{)', Name.Other, 'slashstartsregex'),
513
- # Match stuff like: (function: return type)
514
- (r'([\w?.$][\w?.$]*)(\s*:\s*)([\w?.$][\w?.$]*)',
515
- bygroups(Name.Other, Text, Keyword.Type)),
516
- (r'[$a-zA-Z_]\w*', Name.Other),
517
- (r'0[bB][01]+n?', Number.Bin),
518
- (r'0[oO]?[0-7]+n?', Number.Oct), # Browsers support "0o7" and "07" (< ES5) notations
519
- (r'0[xX][0-9a-fA-F]+n?', Number.Hex),
520
- (r'[0-9]+n', Number.Integer),
521
- (r'(\.[0-9]+|[0-9]+\.[0-9]*|[0-9]+)([eE][-+]?[0-9]+)?', Number.Float),
522
- (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
523
- (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
524
- (r'`', String.Backtick, 'interp'),
525
- # Match stuff like: Decorators
526
- (r'@\w+', Keyword.Declaration),
527
- ],
528
-
529
- # The 'interp*' rules match those in JavascriptLexer. Changes made
530
- # there should be reflected here as well.
531
- 'interp': [
532
- (r'`', String.Backtick, '#pop'),
533
- (r'\\.', String.Backtick),
534
- (r'\$\{', String.Interpol, 'interp-inside'),
535
- (r'\$', String.Backtick),
536
- (r'[^`\\$]+', String.Backtick),
537
- ],
538
- 'interp-inside': [
539
- # TODO: should this include single-line comments and allow nesting strings?
540
- (r'\}', String.Interpol, '#pop'),
541
- include('root'),
542
- ],
543
- }
544
-
545
-
546
503
  class LassoLexer(RegexLexer):
547
504
  """
548
505
  For `Lasso <http://www.lassosoft.com/>`_ source code, covering both Lasso 9
@@ -1033,7 +990,7 @@ class CoffeeScriptLexer(RegexLexer):
1033
990
  """
1034
991
 
1035
992
  name = 'CoffeeScript'
1036
- aliases = ['coffee-script', 'coffeescript', 'coffee']
993
+ aliases = ['coffeescript', 'coffee-script', 'coffee']
1037
994
  filenames = ['*.coffee']
1038
995
  mimetypes = ['text/coffeescript']
1039
996
 
@@ -1051,7 +1008,7 @@ class CoffeeScriptLexer(RegexLexer):
1051
1008
  ],
1052
1009
  'multilineregex': [
1053
1010
  (r'[^/#]+', String.Regex),
1054
- (r'///([gimuys]+\b|\B)', String.Regex, '#pop'),
1011
+ (r'///([gimuysd]+\b|\B)', String.Regex, '#pop'),
1055
1012
  (r'#\{', String.Interpol, 'interpoling_string'),
1056
1013
  (r'[/#]', String.Regex),
1057
1014
  ],
@@ -1059,7 +1016,7 @@ class CoffeeScriptLexer(RegexLexer):
1059
1016
  include('commentsandwhitespace'),
1060
1017
  (r'///', String.Regex, ('#pop', 'multilineregex')),
1061
1018
  (r'/(?! )(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
1062
- r'([gimuys]+\b|\B)', String.Regex, '#pop'),
1019
+ r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
1063
1020
  # This isn't really guarding against mishighlighting well-formed
1064
1021
  # code, just the ability to infinite-loop between root and
1065
1022
  # slashstartsregex.
@@ -1493,7 +1450,7 @@ class JuttleLexer(RegexLexer):
1493
1450
  'slashstartsregex': [
1494
1451
  include('commentsandwhitespace'),
1495
1452
  (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
1496
- r'([gimuys]+\b|\B)', String.Regex, '#pop'),
1453
+ r'([gimuysd]+\b|\B)', String.Regex, '#pop'),
1497
1454
  (r'(?=/)', Text, ('#pop', 'badregex')),
1498
1455
  default('#pop')
1499
1456
  ],
@@ -1534,3 +1491,64 @@ class JuttleLexer(RegexLexer):
1534
1491
  ]
1535
1492
 
1536
1493
  }
1494
+
1495
+
1496
+ class NodeConsoleLexer(Lexer):
1497
+ """
1498
+ For parsing within an interactive Node.js REPL, such as:
1499
+
1500
+ .. sourcecode:: nodejsrepl
1501
+
1502
+ > let a = 3
1503
+ undefined
1504
+ > a
1505
+ 3
1506
+ > let b = '4'
1507
+ undefined
1508
+ > b
1509
+ '4'
1510
+ > b == a
1511
+ false
1512
+
1513
+ .. versionadded: 2.10
1514
+ """
1515
+ name = 'Node.js REPL console session'
1516
+ aliases = ['nodejsrepl', ]
1517
+ mimetypes = ['text/x-nodejsrepl', ]
1518
+
1519
+ def get_tokens_unprocessed(self, text):
1520
+ jslexer = JavascriptLexer(**self.options)
1521
+
1522
+ curcode = ''
1523
+ insertions = []
1524
+
1525
+ for match in line_re.finditer(text):
1526
+ line = match.group()
1527
+ if line.startswith('> '):
1528
+ insertions.append((len(curcode),
1529
+ [(0, Generic.Prompt, line[:2])]))
1530
+
1531
+ curcode += line[2:]
1532
+ elif line.startswith('...'):
1533
+ # node does a nested ... thing depending on depth
1534
+ code = line.lstrip('.')
1535
+ lead = len(line) - len(code)
1536
+
1537
+ insertions.append((len(curcode),
1538
+ [(0, Generic.Prompt, line[:lead])]))
1539
+
1540
+ curcode += code
1541
+ else:
1542
+ if curcode:
1543
+ yield from do_insertions(insertions,
1544
+ jslexer.get_tokens_unprocessed(curcode))
1545
+
1546
+ curcode = ''
1547
+ insertions = []
1548
+
1549
+ yield from do_insertions([],
1550
+ jslexer.get_tokens_unprocessed(line))
1551
+
1552
+ if curcode:
1553
+ yield from do_insertions(insertions,
1554
+ jslexer.get_tokens_unprocessed(curcode))
@@ -0,0 +1,94 @@
1
+ """
2
+ pygments.lexers.jslt
3
+ ~~~~~~~~~~~~~~~~~~~~
4
+
5
+ Lexers for the JSLT language
6
+
7
+ :copyright: Copyright 2021 by the Pygments team, see AUTHORS
8
+ :license: BSD, see LICENSE for details
9
+ """
10
+
11
+ from pygments.lexer import RegexLexer, combined, words
12
+ from pygments.token import Comment, Keyword, Name, Number, Operator, \
13
+ Punctuation, String, Whitespace
14
+
15
+
16
+ __all__ = ['JSLTLexer']
17
+
18
+
19
+ _WORD_END = r'(?=[^0-9A-Z_a-z-])'
20
+
21
+
22
+ class JSLTLexer(RegexLexer):
23
+ """
24
+ For `JSLT <https://github.com/schibsted/jslt>`_ source.
25
+
26
+ .. versionadded:: 2.10
27
+ """
28
+ name = 'JSLT'
29
+ filenames = ['*.jslt']
30
+ aliases = ['jslt']
31
+ mimetypes = ['text/x-jslt']
32
+
33
+ tokens = {
34
+ 'root': [
35
+ (r'[\t\n\f\r ]+', Whitespace),
36
+ (r'//.*(\n|\Z)', Comment.Single),
37
+ (r'-?(0|[1-9][0-9]*)', Number.Integer),
38
+ (r'-?(0|[1-9][0-9]*)(.[0-9]+a)?([Ee][+-]?[0-9]+)', Number.Float),
39
+ (r'"([^"\\]|\\.)*"', String.Double),
40
+ (r'[(),:\[\]{}]', Punctuation),
41
+ (r'(!=|[<=>]=?)', Operator),
42
+ (r'[*+/|-]', Operator),
43
+ (r'\.', Operator),
44
+ (words(('import',), suffix=_WORD_END), Keyword.Namespace, combined('import-path', 'whitespace')),
45
+ (words(('as',), suffix=_WORD_END), Keyword.Namespace, combined('import-alias', 'whitespace')),
46
+ (words(('let',), suffix=_WORD_END), Keyword.Declaration, combined('constant', 'whitespace')),
47
+ (words(('def',), suffix=_WORD_END), Keyword.Declaration, combined('function', 'whitespace')),
48
+ (words(('false', 'null', 'true'), suffix=_WORD_END), Keyword.Constant),
49
+ (words(('else', 'for', 'if'), suffix=_WORD_END), Keyword),
50
+ (words(('and', 'or'), suffix=_WORD_END), Operator.Word),
51
+ (words((
52
+ 'all', 'any', 'array', 'boolean', 'capture', 'ceiling',
53
+ 'contains', 'ends-with', 'error', 'flatten', 'floor',
54
+ 'format-time', 'from-json', 'get-key', 'hash-int', 'index-of',
55
+ 'is-array', 'is-boolean', 'is-decimal', 'is-integer',
56
+ 'is-number', 'is-object', 'is-string', 'join', 'lowercase',
57
+ 'max', 'min', 'mod', 'not', 'now', 'number', 'parse-time',
58
+ 'parse-url', 'random', 'replace', 'round', 'sha256-hex', 'size',
59
+ 'split', 'starts-with', 'string', 'sum', 'test', 'to-json',
60
+ 'trim', 'uppercase', 'zip', 'zip-with-index', 'fallback'), suffix=_WORD_END),
61
+ Name.Builtin),
62
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*:[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function),
63
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name),
64
+ (r'\$[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),
65
+ ],
66
+ 'constant': [
67
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable, 'root'),
68
+ ],
69
+ 'function': [
70
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function, combined('function-parameter-list', 'whitespace')),
71
+ ],
72
+ 'function-parameter-list': [
73
+ (r'\(', Punctuation, combined('function-parameters', 'whitespace')),
74
+ ],
75
+ 'function-parameters': [
76
+ (r',', Punctuation),
77
+ (r'\)', Punctuation, 'root'),
78
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),
79
+ ],
80
+ 'import-path': [
81
+ (r'"([^"]|\\.)*"', String.Symbol, 'root'),
82
+ ],
83
+ 'import-alias': [
84
+ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Namespace, 'root'),
85
+ ],
86
+ 'string': [
87
+ (r'"', String.Double, '#pop'),
88
+ (r'\\.', String.Escape),
89
+ ],
90
+ 'whitespace': [
91
+ (r'[\t\n\f\r ]+', Whitespace),
92
+ (r'//.*(\n|\Z)', Comment.Single),
93
+ ]
94
+ }