rouge 4.1.0 → 4.2.1

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -7
  3. data/lib/rouge/cli.rb +2 -4
  4. data/lib/rouge/demos/codeowners +6 -0
  5. data/lib/rouge/demos/svelte +29 -0
  6. data/lib/rouge/guessers/disambiguation.rb +7 -0
  7. data/lib/rouge/lexers/ada.rb +1 -1
  8. data/lib/rouge/lexers/bpf.rb +10 -10
  9. data/lib/rouge/lexers/clean.rb +4 -4
  10. data/lib/rouge/lexers/codeowners.rb +30 -0
  11. data/lib/rouge/lexers/cpp.rb +1 -1
  12. data/lib/rouge/lexers/dart.rb +6 -6
  13. data/lib/rouge/lexers/dot.rb +1 -0
  14. data/lib/rouge/lexers/ecl.rb +2 -2
  15. data/lib/rouge/lexers/elixir.rb +5 -1
  16. data/lib/rouge/lexers/gdscript.rb +4 -4
  17. data/lib/rouge/lexers/ghc_cmm.rb +3 -3
  18. data/lib/rouge/lexers/groovy.rb +3 -3
  19. data/lib/rouge/lexers/hcl.rb +3 -2
  20. data/lib/rouge/lexers/irb.rb +7 -1
  21. data/lib/rouge/lexers/javascript.rb +8 -1
  22. data/lib/rouge/lexers/jinja.rb +10 -10
  23. data/lib/rouge/lexers/julia.rb +3 -2
  24. data/lib/rouge/lexers/kotlin.rb +1 -1
  25. data/lib/rouge/lexers/liquid.rb +164 -164
  26. data/lib/rouge/lexers/make.rb +1 -1
  27. data/lib/rouge/lexers/meson.rb +0 -1
  28. data/lib/rouge/lexers/mosel.rb +0 -4
  29. data/lib/rouge/lexers/nasm.rb +5 -4
  30. data/lib/rouge/lexers/nginx.rb +1 -0
  31. data/lib/rouge/lexers/objective_c/common.rb +0 -2
  32. data/lib/rouge/lexers/ocl.rb +2 -2
  33. data/lib/rouge/lexers/openedge.rb +581 -378
  34. data/lib/rouge/lexers/php.rb +2 -2
  35. data/lib/rouge/lexers/plsql.rb +5 -5
  36. data/lib/rouge/lexers/python.rb +19 -5
  37. data/lib/rouge/lexers/ruby.rb +3 -2
  38. data/lib/rouge/lexers/rust.rb +7 -6
  39. data/lib/rouge/lexers/scala.rb +5 -2
  40. data/lib/rouge/lexers/shell.rb +6 -2
  41. data/lib/rouge/lexers/sql.rb +1 -1
  42. data/lib/rouge/lexers/svelte.rb +91 -0
  43. data/lib/rouge/lexers/swift.rb +32 -16
  44. data/lib/rouge/lexers/syzlang.rb +0 -1
  45. data/lib/rouge/lexers/terraform.rb +0 -8
  46. data/lib/rouge/lexers/toml.rb +12 -12
  47. data/lib/rouge/lexers/ttcn3.rb +0 -2
  48. data/lib/rouge/lexers/twig.rb +9 -9
  49. data/lib/rouge/lexers/typescript.rb +2 -2
  50. data/lib/rouge/lexers/wollok.rb +6 -2
  51. data/lib/rouge/lexers/xojo.rb +6 -6
  52. data/lib/rouge/lexers/xquery.rb +1 -1
  53. data/lib/rouge/lexers/yang.rb +1 -1
  54. data/lib/rouge/tex_theme_renderer.rb +1 -1
  55. data/lib/rouge/version.rb +1 -1
  56. metadata +7 -3
@@ -66,7 +66,7 @@ module Rouge
66
66
 
67
67
  id = /[\p{L}_][\p{L}\p{N}_]*/
68
68
  ns = /(?:#{id}\\)+/
69
- id_with_ns = /(?:#{ns})?#{id}/
69
+ id_with_ns = /\\?(?:#{ns})?#{id}/
70
70
 
71
71
  start do
72
72
  case @start_inline
@@ -273,7 +273,7 @@ module Rouge
273
273
  state :in_catch do
274
274
  rule %r/\(/, Punctuation
275
275
  rule %r/\|/, Operator
276
- rule id, Name::Class
276
+ rule id_with_ns, Name::Class
277
277
  mixin :escape
278
278
  mixin :whitespace
279
279
  mixin :return
@@ -472,7 +472,7 @@ module Rouge
472
472
  # A double-quoted string refers to a database object in our default SQL
473
473
  rule %r/"/, Operator, :double_string
474
474
  # preprocessor directive treated as special comment
475
- rule %r/(\$(?:IF|THEN|ELSE|ELSIF|ERROR|END|(?:\$\$?\w[\w\d]*)))(\s+)/im do
475
+ rule %r/(\$(?:IF|THEN|ELSE|ELSIF|ERROR|END|(?:\$\$?[a-z]\w*)))(\s+)/im do
476
476
  groups Comment::Preproc, Text
477
477
  end
478
478
 
@@ -503,7 +503,7 @@ module Rouge
503
503
  # Special processing for keywords with multiple contexts
504
504
  #
505
505
  # this madness is to keep the word "replace" from being treated as a builtin function in this context
506
- rule %r/(create)(\s+)(?:(or)(\s+)(replace)(\s+))?(package|function|procedure|type)(?:(\s+)(body))?(\s+)(\w[\w\d\$]*)/im do
506
+ rule %r/(create)(\s+)(?:(or)(\s+)(replace)(\s+))?(package|function|procedure|type)(?:(\s+)(body))?(\s+)([a-z][\w$]*)/im do
507
507
  groups Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Keyword::Reserved, Text, Name
508
508
  end
509
509
  # similar for MERGE keywords
@@ -515,7 +515,7 @@ module Rouge
515
515
  # General keyword classification with sepcial attention to names
516
516
  # in a chained "dot" notation.
517
517
  #
518
- rule %r/(\w[\w\d\$]*)(\.(?=\w))?/ do |m|
518
+ rule %r/([a-zA-Z][\w$]*)(\.(?=\w))?/ do |m|
519
519
  if self.class.keywords_type.include? m[1].upcase
520
520
  tok = Keyword::Type
521
521
  elsif self.class.keywords_func.include? m[1].upcase
@@ -556,11 +556,11 @@ module Rouge
556
556
 
557
557
  state :dotnames do
558
558
  # if we are followed by a dot and another name, we are an ordinary name
559
- rule %r/(\w[\w\d\$]*)(\.(?=\w))/ do
559
+ rule %r/([a-zA-Z][\w\$]*)(\.(?=\w))/ do
560
560
  groups Name, Punctuation
561
561
  end
562
562
  # this rule WILL be true if something pushed into our state. That is our state contract
563
- rule %r/\w[\w\d\$]*/ do |m|
563
+ rule %r/[a-zA-Z][\w\$]*/ do |m|
564
564
  if self.class.keywords_func.include? m[0].upcase
565
565
  # The Function lookup allows collection methods like COUNT, FIRST, LAST, etc.. to be
566
566
  # classified correctly. Occasionally misidentifies ordinary names as builtin functions,
@@ -8,8 +8,8 @@ module Rouge
8
8
  desc "The Python programming language (python.org)"
9
9
  tag 'python'
10
10
  aliases 'py'
11
- filenames '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac',
12
- '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE'
11
+ filenames '*.py', '*.pyi', '*.pyw', '*.sc', 'SConstruct', 'SConscript',
12
+ '*.tac', '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE'
13
13
  mimetypes 'text/x-python', 'application/x-python'
14
14
 
15
15
  def self.detect?(text)
@@ -80,6 +80,8 @@ module Rouge
80
80
  groups Punctuation, Text, Str::Doc
81
81
  end
82
82
 
83
+ rule %r/\.\.\.\B$/, Name::Builtin::Pseudo
84
+
83
85
  rule %r/[^\S\n]+/, Text
84
86
  rule %r(#(.*)?\n?), Comment::Single
85
87
  rule %r/[\[\]{}:(),;.]/, Punctuation
@@ -120,7 +122,7 @@ module Rouge
120
122
  # TODO: not in python 3
121
123
  rule %r/`.*?`/, Str::Backtick
122
124
  rule %r/([rfbu]{0,2})('''|"""|['"])/i do |m|
123
- groups Str::Affix, Str
125
+ groups Str::Affix, Str::Heredoc
124
126
  current_string.register type: m[1].downcase, delim: m[2]
125
127
  push :generic_string
126
128
  end
@@ -178,11 +180,12 @@ module Rouge
178
180
  end
179
181
 
180
182
  state :generic_string do
181
- rule %r/[^'"\\{]+/, Str
183
+ rule %r/^\s*(>>>|\.\.\.)\B/, Generic::Prompt, :doctest
184
+ rule %r/[^'"\\{]+?/, Str
182
185
  rule %r/{{/, Str
183
186
 
184
187
  rule %r/'''|"""|['"]/ do |m|
185
- token Str
188
+ token Str::Heredoc
186
189
  if current_string.delim? m[0]
187
190
  current_string.remove
188
191
  pop!
@@ -220,6 +223,17 @@ module Rouge
220
223
  rule %r/\\./, Str, :pop!
221
224
  end
222
225
 
226
+ state :doctest do
227
+ rule %r/\n\n/, Text, :pop!
228
+
229
+ rule %r/'''|"""/ do
230
+ token Str::Heredoc
231
+ pop!(2) if in_state?(:generic_string) # pop :doctest and :generic_string
232
+ end
233
+
234
+ mixin :root
235
+ end
236
+
223
237
  state :generic_interpol do
224
238
  rule %r/[^{}!:]+/ do |m|
225
239
  recurse m[0]
@@ -42,7 +42,7 @@ module Rouge
42
42
  rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
43
43
  open = Regexp.escape(m[2])
44
44
  close = Regexp.escape(delimiter_map[m[2]] || m[2])
45
- interp = /[rQWxI]/ === m[1]
45
+ interp = /[rQWxI]/ === m[1] || !m[1]
46
46
  toktype = Str::Other
47
47
 
48
48
  puts " open: #{open.inspect}" if @debug
@@ -57,7 +57,7 @@ module Rouge
57
57
  token toktype
58
58
 
59
59
  push do
60
- uniq_chars = "#{open}#{close}".squeeze
60
+ uniq_chars = [open, close].uniq.join
61
61
  uniq_chars = '' if open == close && open == "\\#"
62
62
  rule %r/\\[##{uniq_chars}\\]/, Str::Escape
63
63
  # nesting rules only with asymmetric delimiters
@@ -188,6 +188,7 @@ module Rouge
188
188
 
189
189
  rule %r/(?:#{keywords.join('|')})(?=\W|$)/, Keyword, :expr_start
190
190
  rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
191
+ rule %r/(not|and|or)\b/, Operator::Word, :expr_start
191
192
 
192
193
  rule %r(
193
194
  (module)
@@ -35,17 +35,18 @@ module Rouge
35
35
  def self.builtins
36
36
  @builtins ||= Set.new %w(
37
37
  Add BitAnd BitOr BitXor bool c_char c_double c_float char
38
- c_int clock_t c_long c_longlong Cons Const Copy c_schar c_short
38
+ c_int clock_t c_long c_longlong Copy c_schar c_short
39
39
  c_uchar c_uint c_ulong c_ulonglong c_ushort c_void dev_t DIR
40
- dirent Div Either Eq Err f32 f64 Failure FILE float fpos_t
41
- i16 i32 i64 i8 isize Index ino_t int intptr_t Left mode_t Modulo Mul
42
- Neg Nil None Num off_t Ok Option Ord Owned pid_t Ptr ptrdiff_t
43
- Right Send Shl Shr size_t Some ssize_t str Sub Success time_t
40
+ dirent Div Eq Err f32 f64 FILE float fpos_t
41
+ i16 i32 i64 i8 isize Index ino_t int intptr_t mode_t Mul
42
+ Neg None off_t Ok Option Ord Owned pid_t ptrdiff_t
43
+ Send Shl Shr size_t Some ssize_t str Sub time_t
44
44
  u16 u32 u64 u8 usize uint uintptr_t
45
- Box Vec String Gc Rc Arc
45
+ Box Vec String Rc Arc
46
46
  u128 i128 Result Sync Pin Unpin Sized Drop drop Fn FnMut FnOnce
47
47
  Clone PartialEq PartialOrd AsMut AsRef From Into Default
48
48
  DoubleEndedIterator ExactSizeIterator Extend IntoIterator Iterator
49
+ FromIterator ToOwned ToString TryFrom TryInto
49
50
  )
50
51
  end
51
52
 
@@ -13,7 +13,8 @@ module Rouge
13
13
  mimetypes 'text/x-scala', 'application/x-scala'
14
14
 
15
15
  # As documented in the ENBF section of the scala specification
16
- # http://www.scala-lang.org/docu/files/ScalaReference.pdf
16
+ # https://scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html
17
+ # https://en.wikipedia.org/wiki/Unicode_character_property#General_Category
17
18
  whitespace = /\p{Space}/
18
19
  letter = /[\p{L}$_]/
19
20
  upper = /[\p{Lu}$_]/
@@ -24,8 +25,10 @@ module Rouge
24
25
  # negative lookahead to filter out other classes
25
26
  op = %r(
26
27
  (?!#{whitespace}|#{letter}|#{digits}|#{parens}|#{delims})
27
- [\u0020-\u007F\p{Sm}\p{So}]
28
+ [-!#%&*/:?@\\^\p{Sm}\p{So}]
28
29
  )x
30
+ # manually removed +<=>|~ from regexp because they're in property Sm
31
+ # pp CHRS:(0x00..0x7f).map(&:chr).grep(/\p{Sm}/)
29
32
 
30
33
  idrest = %r(#{letter}(?:#{letter}|#{digits})*(?:(?<=_)#{op}+)?)x
31
34
 
@@ -9,8 +9,11 @@ module Rouge
9
9
 
10
10
  tag 'shell'
11
11
  aliases 'bash', 'zsh', 'ksh', 'sh'
12
- filenames '*.sh', '*.bash', '*.zsh', '*.ksh', '.bashrc', '.zshrc',
13
- '.kshrc', '.profile', 'APKBUILD', 'PKGBUILD', '*.ebuild',
12
+ filenames '*.sh', '*.bash', '*.zsh', '*.ksh', '.bashrc',
13
+ '.kshrc', '.profile',
14
+ '.zshenv', '.zprofile', '.zshrc', '.zlogin', '.zlogout',
15
+ 'zshenv', 'zprofile', 'zshrc', 'zlogin', 'zlogout',
16
+ 'APKBUILD', 'PKGBUILD', '*.ebuild',
14
17
  '*.eclass', '*.exheres-0', '*.exlib'
15
18
 
16
19
  mimetypes 'application/x-sh', 'application/x-shellscript', 'text/x-sh',
@@ -18,6 +21,7 @@ module Rouge
18
21
 
19
22
  def self.detect?(text)
20
23
  return true if text.shebang?(/(ba|z|k)?sh/)
24
+ return true if text.start_with?('#compdef', '#autoload')
21
25
  end
22
26
 
23
27
  KEYWORDS = %w(
@@ -115,7 +115,7 @@ module Rouge
115
115
  rule %r/"/, Name::Variable, :double_string
116
116
  rule %r/`/, Name::Variable, :backtick
117
117
 
118
- rule %r/\w[\w\d]*/ do |m|
118
+ rule %r/\w+/ do |m|
119
119
  if self.class.keywords_type.include? m[0].upcase
120
120
  token Name::Builtin
121
121
  elsif self.class.keywords.include? m[0].upcase
@@ -0,0 +1,91 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ load_lexer 'html.rb'
7
+
8
+ class Svelte < HTML
9
+ desc 'Svelte single-file components (https://svelte.dev/)'
10
+ tag 'svelte'
11
+ filenames '*.svelte'
12
+ mimetypes 'text/x-svelte', 'application/x-svelte'
13
+
14
+ def initialize(*)
15
+ super
16
+ # todo add support for typescript script blocks
17
+ @js = Javascript.new(options)
18
+ end
19
+
20
+ # Shorthand syntax for passing attributes - ex, `{src}` instead of `src={src}`
21
+ prepend :tag do
22
+ rule %r/(\{)\s*([a-zA-Z0-9_]+)\s*(})/m do
23
+ groups Str::Interpol, Name::Variable, Str::Interpol
24
+ pop!
25
+ end
26
+ end
27
+
28
+ prepend :attr do
29
+ # Duplicate template_start mixin here with a pop!
30
+ # Because otherwise we'll never exit the attr state
31
+ rule %r/\{/ do
32
+ token Str::Interpol
33
+ pop!
34
+ push :template
35
+ end
36
+ end
37
+
38
+ # handle templates within attribute single/double quotes
39
+ prepend :dq do
40
+ mixin :template_start
41
+ end
42
+
43
+ prepend :sq do
44
+ mixin :template_start
45
+ end
46
+
47
+ prepend :root do
48
+ # detect curly braces within HTML text (outside of tags/attributes)
49
+ rule %r/([^<&{]*)(\{)(\s*)/ do
50
+ groups Text, Str::Interpol, Text
51
+ push :template
52
+ end
53
+ end
54
+
55
+ state :template_start do
56
+ # open template
57
+ rule %r/\s*\{\s*/, Str::Interpol, :template
58
+ end
59
+
60
+ state :template do
61
+ # template end
62
+ rule %r/}/, Str::Interpol, :pop!
63
+
64
+ # Allow JS lexer to handle matched curly braces within template
65
+ rule(/(?<=^|[^\\])\{.*?(?<=^|[^\\])\}/) do
66
+ delegate @js
67
+ end
68
+
69
+ # keywords
70
+ rule %r/@(debug|html)\b/, Keyword
71
+ rule %r/(#await)(.*)(then|catch)(\s+)(\w+)/ do |m|
72
+ token Keyword, m[1]
73
+ delegate @js, m[2]
74
+ token Keyword, m[3]
75
+ token Text, m[4]
76
+ delegate @js, m[5]
77
+ end
78
+ rule %r/([#\/])(await|each|if|key)\b/, Keyword
79
+ rule %r/(:else)(\s+)(if)?\b/ do
80
+ groups Keyword, Text, Keyword
81
+ end
82
+ rule %r/:?(catch|then)\b/, Keyword
83
+
84
+ # allow JS parser to handle anything that's not a curly brace
85
+ rule %r/[^{}]+/ do
86
+ delegate @js
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -15,28 +15,29 @@ module Rouge
15
15
  id = /#{id_head}#{id_rest}*/
16
16
 
17
17
  keywords = Set.new %w(
18
- await break case continue default do else fallthrough if in for return switch where while try catch throw guard defer repeat
18
+ autoreleasepool await break case catch consume continue default defer discard do each else fallthrough guard if in for repeat return switch throw try where while
19
19
 
20
- as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
20
+ as dynamicType is new super self Self Type
21
21
 
22
- associativity async didSet get infix inout isolated mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
23
-
24
- #available #colorLiteral #column #else #elseif #endif #error #file #fileLiteral #function #if #imageLiteral #line #selector #sourceLocation #warning
22
+ associativity async didSet get infix inout isolated left mutating none nonmutating operator override postfix precedence precedencegroup prefix rethrows right set throws unowned weak willSet
25
23
  )
26
24
 
27
25
  declarations = Set.new %w(
28
- actor class deinit enum convenience extension final func import init internal lazy let nonisolated optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
26
+ actor any associatedtype borrowing class consuming deinit distributed dynamic enum convenience extension fileprivate final func import indirect init internal lazy let macro nonisolated open optional package private protocol public required some static struct subscript typealias var
29
27
  )
30
28
 
31
29
  constants = Set.new %w(
32
30
  true false nil
33
31
  )
34
32
 
35
- start { push :bol }
33
+ start do
34
+ push :bol
35
+ @re_delim = "" # multi-line regex delimiter
36
+ end
36
37
 
37
38
  # beginning of line
38
39
  state :bol do
39
- rule %r/#.*/, Comment::Preproc
40
+ rule %r/#(?![#"\/]).*/, Comment::Preproc
40
41
 
41
42
  mixin :inline_whitespace
42
43
 
@@ -69,8 +70,11 @@ module Rouge
69
70
  mixin :whitespace
70
71
 
71
72
  rule %r/\$(([1-9]\d*)?\d)/, Name::Variable
73
+ rule %r/\$#{id}/, Name
74
+ rule %r/~Copyable\b/, Keyword::Type
72
75
 
73
76
  rule %r{[()\[\]{}:;,?\\]}, Punctuation
77
+ rule %r{(#*)/(?!\s).*(?<![\s\\])/\1}, Str::Regex
74
78
  rule %r([-/=+*%<>!&|^.~]+), Operator
75
79
  rule %r/@?"/, Str, :dq
76
80
  rule %r/'(\\.|.)'/, Str::Char
@@ -82,6 +86,7 @@ module Rouge
82
86
  rule %r{[\d]+(?:_\d+)*}, Num::Integer
83
87
 
84
88
  rule %r/@#{id}/, Keyword::Declaration
89
+ rule %r/##{id}/, Keyword
85
90
 
86
91
  rule %r/(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m|
87
92
  if m[3] == 'set'
@@ -99,14 +104,6 @@ module Rouge
99
104
  end
100
105
  end
101
106
 
102
- rule %r/#available\([^)]+\)/, Keyword::Declaration
103
-
104
- rule %r/(#(?:selector|keyPath)\()([^)]+?(?:[(].*?[)])?)(\))/ do
105
- groups Keyword::Declaration, Name::Function, Keyword::Declaration
106
- end
107
-
108
- rule %r/#(line|file|column|function|dsohandle)/, Keyword::Declaration
109
-
110
107
  rule %r/(let|var)\b(\s*)(#{id})/ do
111
108
  groups Keyword, Text, Name::Variable
112
109
  end
@@ -148,6 +145,12 @@ module Rouge
148
145
  rule %r/(`)(#{id})(`)/ do
149
146
  groups Punctuation, Name::Variable, Punctuation
150
147
  end
148
+
149
+ rule %r{(#+)/\n} do |m|
150
+ @re_delim = m[1]
151
+ token Str::Regex
152
+ push :re_multi
153
+ end
151
154
  end
152
155
 
153
156
  state :tuple do
@@ -181,6 +184,19 @@ module Rouge
181
184
  rule %r/[)]/, Punctuation, :pop!
182
185
  mixin :root
183
186
  end
187
+
188
+ state :re_multi do
189
+ rule %r{^\s*/#+} do |m|
190
+ token Str::Regex
191
+ if m[0].end_with?("/#{@re_delim}")
192
+ @re_delim = ""
193
+ pop!
194
+ end
195
+ end
196
+
197
+ rule %r/#.*/, Comment::Single
198
+ rule %r/./m, Str::Regex
199
+ end
184
200
  end
185
201
  end
186
202
  end
@@ -27,7 +27,6 @@ module Rouge
27
27
 
28
28
  comment = /#.*$/
29
29
  inline_spaces = /[ \t]+/
30
- eol_spaces = /[\n\r]+/
31
30
  spaces = /\s+/
32
31
 
33
32
  state :inline_break do
@@ -37,14 +37,6 @@ module Rouge
37
37
  @builtins ||= %w()
38
38
  end
39
39
 
40
- prepend :hash do
41
- rule %r/[.,()*]/, Punctuation
42
- end
43
-
44
- prepend :array do
45
- rule %r/[.,()*]/, Punctuation
46
- end
47
-
48
40
  state :strings do
49
41
  rule %r/\\./, Str::Escape
50
42
  rule %r/\$\{/ do
@@ -20,20 +20,9 @@ module Rouge
20
20
  rule %r/(true|false)/, Keyword::Constant
21
21
 
22
22
  rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do
23
- groups Name::Namespace, Text, Operator, Text, Punctuation
23
+ groups Name::Property, Text, Operator, Text, Punctuation
24
24
  push :inline
25
25
  end
26
-
27
- rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
28
-
29
- rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
30
- rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float
31
- rule %r/[+-]?(?:nan|inf)/, Num::Float
32
-
33
- rule %r/0x\h+(?:_\h+)*/, Num::Hex
34
- rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
35
- rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
36
- rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer
37
26
  end
38
27
 
39
28
  state :root do
@@ -59,6 +48,17 @@ module Rouge
59
48
  groups Name::Property, Text, Punctuation
60
49
  end
61
50
 
51
+ rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
52
+
53
+ rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
54
+ rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float
55
+ rule %r/[+-]?(?:nan|inf)/, Num::Float
56
+
57
+ rule %r/0x\h+(?:_\h+)*/, Num::Hex
58
+ rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
59
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
60
+ rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer
61
+
62
62
  rule %r/"""/, Str, :mdq
63
63
  rule %r/"/, Str, :dq
64
64
  rule %r/'''/, Str, :msq
@@ -46,8 +46,6 @@ module Rouge
46
46
  )
47
47
  end
48
48
 
49
- # optional comment or whitespace
50
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
51
49
  id = /[a-zA-Z_]\w*/
52
50
  digit = /\d_+\d|\d/
53
51
  bin_digit = /[01]_+[01]|[01]/
@@ -16,24 +16,24 @@ module Rouge
16
16
  mimetypes 'application/x-twig', 'text/html+twig'
17
17
 
18
18
  def self.keywords
19
- @@keywords ||= %w(as do extends flush from import include use else starts
20
- ends with without autoescape endautoescape block
21
- endblock embed endembed filter endfilter for endfor
22
- if endif macro endmacro sandbox endsandbox set endset
23
- spaceless endspaceless)
19
+ @keywords ||= %w(as do extends flush from import include use else starts
20
+ ends with without autoescape endautoescape block
21
+ endblock embed endembed filter endfilter for endfor
22
+ if endif macro endmacro sandbox endsandbox set endset
23
+ spaceless endspaceless)
24
24
  end
25
25
 
26
26
  def self.tests
27
- @@tests ||= %w(constant defined divisibleby empty even iterable null odd
28
- sameas)
27
+ @tests ||= %w(constant defined divisibleby empty even iterable null odd
28
+ sameas)
29
29
  end
30
30
 
31
31
  def self.pseudo_keywords
32
- @@pseudo_keywords ||= %w(true false none)
32
+ @pseudo_keywords ||= %w(true false none)
33
33
  end
34
34
 
35
35
  def self.word_operators
36
- @@word_operators ||= %w(b-and b-or b-xor is in and or not)
36
+ @word_operators ||= %w(b-and b-or b-xor is in and or not)
37
37
  end
38
38
  end
39
39
  end
@@ -10,12 +10,12 @@ module Rouge
10
10
  extend TypescriptCommon
11
11
 
12
12
  title "TypeScript"
13
- desc "TypeScript, a superset of JavaScript"
13
+ desc "TypeScript, a superset of JavaScript (https://www.typescriptlang.org/)"
14
14
 
15
15
  tag 'typescript'
16
16
  aliases 'ts'
17
17
 
18
- filenames '*.ts', '*.d.ts'
18
+ filenames '*.ts', '*.d.ts', '*.cts', '*.mts'
19
19
 
20
20
  mimetypes 'text/typescript'
21
21
  end
@@ -14,8 +14,6 @@ module Rouge
14
14
  entity_name = /[a-zA-Z][a-zA-Z0-9]*/
15
15
  variable_naming = /_?#{entity_name}/
16
16
 
17
- entities = []
18
-
19
17
  state :whitespaces_and_comments do
20
18
  rule %r/\s+/m, Text::Whitespace
21
19
  rule %r(//.*$), Comment::Single
@@ -98,6 +96,12 @@ module Rouge
98
96
  rule %r/\(|\)|=/, Text
99
97
  rule %r/,/, Punctuation
100
98
  end
99
+
100
+ private
101
+
102
+ def entities
103
+ @entities ||= []
104
+ end
101
105
  end
102
106
  end
103
107
  end
@@ -12,20 +12,20 @@ module Rouge
12
12
 
13
13
  keywords = %w(
14
14
  addhandler aggregates array asc assigns attributes begin break
15
- byref byval call case catch class const continue char ctype declare
15
+ byref byval call case catch class const continue color ctype declare
16
16
  delegate dim do downto each else elseif end enum event exception
17
17
  exit extends false finally for function global goto if
18
18
  implements inherits interface lib loop mod module
19
19
  new next nil object of optional paramarray
20
20
  private property protected public raise raiseevent rect redim
21
21
  removehandler return select shared soft static step sub super
22
- then to true try until using uend uhile
22
+ then to true try until using var wend while
23
23
  )
24
24
 
25
25
  keywords_type = %w(
26
- boolean cfstringref cgfloat cstring curency date double int8 int16
27
- int32 int64 integer ostype pstring ptr short single
28
- single string structure variant uinteger uint8 uint16 uint32 uint64
26
+ boolean byte cfstringref cgfloat cstring currency date datetime double int8 int16
27
+ int32 int64 integer ostype pair pstring ptr short single
28
+ string structure variant uinteger uint8 uint16 uint32 uint64
29
29
  ushort windowptr wstring
30
30
  )
31
31
 
@@ -37,7 +37,7 @@ module Rouge
37
37
  rule %r/\s+/, Text::Whitespace
38
38
 
39
39
  rule %r/rem\b.*?$/i, Comment::Single
40
- rule %r([//'].*$), Comment::Single
40
+ rule %r((?://|').*$), Comment::Single
41
41
  rule %r/\#tag Note.*?\#tag EndNote/mi, Comment::Preproc
42
42
  rule %r/\s*[#].*$/x, Comment::Preproc
43
43
 
@@ -8,7 +8,7 @@ module Rouge
8
8
  title 'XQuery'
9
9
  desc 'XQuery 3.1: An XML Query Language'
10
10
  tag 'xquery'
11
- filenames '*.xquery', '*.xq'
11
+ filenames '*.xquery', '*.xq', '*.xqm'
12
12
  mimetypes 'application/xquery'
13
13
 
14
14
  def self.keywords
@@ -10,7 +10,7 @@ module Rouge
10
10
  filenames '*.yang'
11
11
  mimetypes 'application/yang'
12
12
 
13
- id = /[\w_-]+(?=[^\w\-\:])\b/
13
+ id = /[\w-]+(?=[^\w\-\:])\b/
14
14
 
15
15
  #Keywords from RFC7950 ; oriented at BNF style
16
16
  def self.top_stmts_keywords
@@ -109,7 +109,7 @@ END
109
109
  end
110
110
 
111
111
  def render_blank(tok, &b)
112
- out = "\\expandafter\\def#{token_name(tok)}#1{#1}"
112
+ "\\expandafter\\def#{token_name(tok)}#1{#1}"
113
113
  end
114
114
 
115
115
  def render_style(tok, style, &b)
data/lib/rouge/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "4.1.0"
6
+ "4.2.1"
7
7
  end
8
8
  end