rouge 3.9.0 → 3.13.0
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.
- checksums.yaml +4 -4
- data/lib/rouge/demos/apex +9 -0
- data/lib/rouge/demos/clean +6 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/jsl +3 -0
- data/lib/rouge/demos/liquid +0 -1
- data/lib/rouge/demos/lustre +6 -0
- data/lib/rouge/demos/lutin +18 -0
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/q +6 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/sparql +6 -0
- data/lib/rouge/demos/ttcn3 +6 -0
- data/lib/rouge/guessers/disambiguation.rb +5 -0
- data/lib/rouge/lexer.rb +3 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/bpf.rb +20 -6
- data/lib/rouge/lexers/clean.rb +156 -0
- data/lib/rouge/lexers/common_lisp.rb +1 -1
- data/lib/rouge/lexers/coq.rb +12 -9
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/eex.rb +2 -1
- data/lib/rouge/lexers/http.rb +1 -1
- data/lib/rouge/lexers/jsl.rb +55 -0
- data/lib/rouge/lexers/json.rb +1 -1
- data/lib/rouge/lexers/kotlin.rb +21 -28
- data/lib/rouge/lexers/liquid.rb +82 -108
- data/lib/rouge/lexers/lustre.rb +79 -0
- data/lib/rouge/lexers/lutin.rb +33 -0
- data/lib/rouge/lexers/markdown.rb +7 -1
- data/lib/rouge/lexers/mason.rb +0 -5
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/perl.rb +1 -1
- data/lib/rouge/lexers/q.rb +2 -1
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/shell.rb +5 -3
- data/lib/rouge/lexers/sparql.rb +129 -0
- data/lib/rouge/lexers/swift.rb +1 -1
- data/lib/rouge/lexers/ttcn3.rb +119 -0
- data/lib/rouge/plugins/redcarpet.rb +7 -1
- data/lib/rouge/version.rb +1 -1
- metadata +22 -2
@@ -7,7 +7,7 @@ module Rouge
|
|
7
7
|
title "Common Lisp"
|
8
8
|
desc "The Common Lisp variant of Lisp (common-lisp.net)"
|
9
9
|
tag 'common_lisp'
|
10
|
-
aliases 'cl', 'common-lisp', 'elisp', 'emacs-lisp'
|
10
|
+
aliases 'cl', 'common-lisp', 'elisp', 'emacs-lisp', 'lisp'
|
11
11
|
|
12
12
|
filenames '*.cl', '*.lisp', '*.asd', '*.el' # used for Elisp too
|
13
13
|
mimetypes 'text/x-common-lisp'
|
data/lib/rouge/lexers/coq.rb
CHANGED
@@ -58,7 +58,7 @@ module Rouge
|
|
58
58
|
|
59
59
|
def self.keyopts
|
60
60
|
@keyopts ||= Set.new %w(
|
61
|
-
:= => -> /\\ \\/ _ ; :> :
|
61
|
+
:= => -> /\\ \\/ _ ; :> : ⇒ → ↔ ⇔ ≔ ≡ ∀ ∃ ∧ ∨ ¬ ⊤ ⊥ ⊢ ⊨ ∈
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
@@ -115,14 +115,6 @@ module Rouge
|
|
115
115
|
end
|
116
116
|
rule %r(/\\), Operator
|
117
117
|
rule %r/\\\//, Operator
|
118
|
-
rule operator do |m|
|
119
|
-
match = m[0]
|
120
|
-
if self.class.keyopts.include? match
|
121
|
-
token Punctuation
|
122
|
-
else
|
123
|
-
token Operator
|
124
|
-
end
|
125
|
-
end
|
126
118
|
|
127
119
|
rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
|
128
120
|
rule %r/\d[\d_]*/, Num::Integer
|
@@ -131,6 +123,17 @@ module Rouge
|
|
131
123
|
rule %r/'/, Keyword
|
132
124
|
rule %r/"/, Str::Double, :string
|
133
125
|
rule %r/[~?]#{id}/, Name::Variable
|
126
|
+
|
127
|
+
rule %r/./ do |m|
|
128
|
+
match = m[0]
|
129
|
+
if self.class.keyopts.include? match
|
130
|
+
token Punctuation
|
131
|
+
elsif match =~ operator
|
132
|
+
token Operator
|
133
|
+
else
|
134
|
+
token Error
|
135
|
+
end
|
136
|
+
end
|
134
137
|
end
|
135
138
|
|
136
139
|
state :comment do
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class CSVS < RegexLexer
|
7
|
+
tag 'csvs'
|
8
|
+
title "csvs"
|
9
|
+
desc 'The CSV Schema Language (digital-preservation.github.io)'
|
10
|
+
filenames '*.csvs'
|
11
|
+
|
12
|
+
state :root do
|
13
|
+
rule %r/\s+/m, Text
|
14
|
+
|
15
|
+
rule %r(//[\S\t ]*), Comment::Single
|
16
|
+
rule %r(/\*[^*]*\*/)m, Comment::Multiline
|
17
|
+
|
18
|
+
rule %r/(version)( )(\d+\.\d+)/ do
|
19
|
+
groups Keyword, Text::Whitespace, Num::Float
|
20
|
+
end
|
21
|
+
|
22
|
+
rule %r/T?\d{2}:\d{2}:\d{2}(\.\d{5})?(Z|(?:[-+]\d{2}:\d{2}))?/, Literal::Date
|
23
|
+
rule %r/\d{4}-\d{2}-\d{2}/, Literal::Date
|
24
|
+
rule %r/\d{2}\/\d{2}\/\d{4}/, Literal::Date
|
25
|
+
|
26
|
+
rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float
|
27
|
+
rule %r/\d+/, Num::Integer
|
28
|
+
|
29
|
+
rule %r/@\w+/, Keyword::Pseudo
|
30
|
+
|
31
|
+
rule %r/[-.\w]+:/, Name::Variable
|
32
|
+
rule %r/^"[^"]+"/, Name::Variable
|
33
|
+
rule %r/\$([-.\w]+|("[^"]+"))\/?/, Name::Variable
|
34
|
+
|
35
|
+
rule %r/[A-Z]+/i, Keyword
|
36
|
+
|
37
|
+
rule %r/"[^"]*"/, Str::Double
|
38
|
+
rule %r/'[^\r\n\f']'/, Str::Char
|
39
|
+
|
40
|
+
rule %r/[,()*]/, Punctuation
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/rouge/lexers/eex.rb
CHANGED
data/lib/rouge/lexers/http.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class JSL < RegexLexer
|
7
|
+
title "JSL"
|
8
|
+
desc "The JMP Scripting Language (JSL) (jmp.com)"
|
9
|
+
|
10
|
+
tag 'jsl'
|
11
|
+
filenames '*.jsl'
|
12
|
+
|
13
|
+
state :root do
|
14
|
+
rule %r/\s+/m, Text::Whitespace
|
15
|
+
|
16
|
+
rule %r(//.*?$), Comment::Single
|
17
|
+
rule %r(/\*.*?\*/)m, Comment::Multiline
|
18
|
+
|
19
|
+
# messages
|
20
|
+
rule %r/(<<)(.*?)(\(|;)/ do |m|
|
21
|
+
groups Operator, Name::Function, Punctuation
|
22
|
+
end
|
23
|
+
|
24
|
+
# covers built-in and custom functions
|
25
|
+
rule %r/([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
26
|
+
groups Keyword, Punctuation
|
27
|
+
end
|
28
|
+
|
29
|
+
rule %r/\b[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+|\.)(?:e[+-]?[0-9]+)?i?\b/i, Num
|
30
|
+
|
31
|
+
rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date
|
32
|
+
|
33
|
+
rule %r/::[a-z_][\w\s'%.\\]*/i, Name::Variable
|
34
|
+
rule %r/:\w+/, Name
|
35
|
+
rule %r/[a-z_][\w\s'%.\\]*/i, Name::Variable
|
36
|
+
rule %r/"(?:\\!"|[^"])*?"n/m, Name::Variable
|
37
|
+
|
38
|
+
rule %r/(")(\\\[)(.*?)(\]\\)(")/m do
|
39
|
+
groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double # escaped string
|
40
|
+
end
|
41
|
+
rule %r/"/, Str::Double, :dq
|
42
|
+
|
43
|
+
rule %r/[-+*\/!%&<>\|=:]/, Operator
|
44
|
+
rule %r/[\[\](){},;]/, Punctuation
|
45
|
+
end
|
46
|
+
|
47
|
+
state :dq do
|
48
|
+
rule %r/\\![btrnNf0\\"]/, Str::Escape
|
49
|
+
rule %r/\\/, Str::Double
|
50
|
+
rule %r/"/, Str::Double, :pop!
|
51
|
+
rule %r/[^\\"]*/m, Str::Double
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/rouge/lexers/json.rb
CHANGED
data/lib/rouge/lexers/kotlin.rb
CHANGED
@@ -24,19 +24,12 @@ module Rouge
|
|
24
24
|
while yield
|
25
25
|
)
|
26
26
|
|
27
|
-
|
28
|
-
name_backtick = %r'#{name}|`#{name}`'
|
27
|
+
name_chars = %r'[-_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
|
29
28
|
|
30
|
-
|
29
|
+
class_name = %r'`?[\p{Lu}]#{name_chars}`?'
|
30
|
+
name = %r'`?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}]#{name_chars}`?'
|
31
31
|
|
32
32
|
state :root do
|
33
|
-
rule %r'(\))(\s*)(:)(\s+)(#{name_backtick})(<)' do
|
34
|
-
groups Punctuation, Text, Punctuation, Text, Name::Class, Punctuation
|
35
|
-
push :generic_parameters
|
36
|
-
end
|
37
|
-
rule %r'(\))(\s*)(:)(\s+)(#{name_backtick})' do
|
38
|
-
groups Punctuation, Text, Punctuation, Text, Name::Class
|
39
|
-
end
|
40
33
|
rule %r'\b(companion)(\s+)(object)\b' do
|
41
34
|
groups Keyword, Text, Keyword
|
42
35
|
end
|
@@ -48,13 +41,6 @@ module Rouge
|
|
48
41
|
groups Keyword, Text
|
49
42
|
push :function
|
50
43
|
end
|
51
|
-
rule %r'(#{name_backtick})(:)(\s+)(#{name_backtick})(<)' do
|
52
|
-
groups Name::Variable, Punctuation, Text, Name::Class, Punctuation
|
53
|
-
push :generic_parameters
|
54
|
-
end
|
55
|
-
rule %r'(#{name_backtick})(:)(\s+)(#{name_backtick})' do
|
56
|
-
groups Name::Variable, Punctuation, Text, Name::Class
|
57
|
-
end
|
58
44
|
rule %r'\b(package|import)(\s+)' do
|
59
45
|
groups Keyword, Text
|
60
46
|
push :package
|
@@ -67,8 +53,8 @@ module Rouge
|
|
67
53
|
groups Keyword::Declaration, Text
|
68
54
|
push :property
|
69
55
|
end
|
70
|
-
rule %r
|
71
|
-
rule %r
|
56
|
+
rule %r'\bfun\b', Keyword
|
57
|
+
rule %r'\b(?:#{keywords.join('|')})\b', Keyword
|
72
58
|
rule %r'^\s*\[.*?\]', Name::Attribute
|
73
59
|
rule %r'[^\S\n]+', Text
|
74
60
|
rule %r'\\\n', Text # line continuation
|
@@ -85,43 +71,50 @@ module Rouge
|
|
85
71
|
rule %r'"(\\\\|\\"|[^"\n])*["\n]'m, Str
|
86
72
|
rule %r"'\\.'|'[^\\]'", Str::Char
|
87
73
|
rule %r"[0-9](\.[0-9]+)?([eE][+-][0-9]+)?[flFL]?|0[xX][0-9a-fA-F]+[Ll]?", Num
|
88
|
-
rule %r
|
89
|
-
rule
|
74
|
+
rule %r'(@#{class_name})', Name::Decorator
|
75
|
+
rule %r'(#{class_name})(<)' do
|
76
|
+
groups Name::Class, Punctuation
|
77
|
+
push :generic_parameters
|
78
|
+
end
|
79
|
+
rule class_name, Name::Class
|
80
|
+
rule %r'(#{name})(?=\s*[({])', Name::Function
|
81
|
+
rule name, Name
|
90
82
|
end
|
91
83
|
|
92
84
|
state :package do
|
93
|
-
rule %r
|
85
|
+
rule %r'\S+', Name::Namespace, :pop!
|
94
86
|
end
|
95
87
|
|
96
88
|
state :class do
|
97
|
-
rule
|
89
|
+
rule class_name, Name::Class, :pop!
|
98
90
|
end
|
99
91
|
|
100
92
|
state :function do
|
101
93
|
rule %r'(<)', Punctuation, :generic_parameters
|
102
94
|
rule %r'(\s+)', Text
|
103
|
-
rule %r'(#{
|
95
|
+
rule %r'(#{class_name})(\.)' do
|
104
96
|
groups Name::Class, Punctuation
|
105
97
|
end
|
106
|
-
rule
|
98
|
+
rule name, Name::Function, :pop!
|
107
99
|
end
|
108
100
|
|
109
101
|
state :generic_parameters do
|
110
|
-
rule
|
102
|
+
rule class_name, Name::Class
|
103
|
+
rule %r'(<)', Punctuation, :generic_parameters
|
111
104
|
rule %r'(,)', Punctuation
|
112
105
|
rule %r'(\s+)', Text
|
113
106
|
rule %r'(>)', Punctuation, :pop!
|
114
107
|
end
|
115
108
|
|
116
109
|
state :property do
|
117
|
-
rule
|
110
|
+
rule name, Name::Property, :pop!
|
118
111
|
end
|
119
112
|
|
120
113
|
state :destructure do
|
121
114
|
rule %r'(,)', Punctuation
|
122
115
|
rule %r'(\))', Punctuation, :pop!
|
123
116
|
rule %r'(\s+)', Text
|
124
|
-
rule
|
117
|
+
rule name, Name::Property
|
125
118
|
end
|
126
119
|
|
127
120
|
state :comment do
|
data/lib/rouge/lexers/liquid.rb
CHANGED
@@ -12,12 +12,12 @@ module Rouge
|
|
12
12
|
state :root do
|
13
13
|
rule %r/[^\{]+/, Text
|
14
14
|
|
15
|
-
rule %r/(\{
|
15
|
+
rule %r/(\{%-?)(\s*)/ do
|
16
16
|
groups Punctuation, Text::Whitespace
|
17
17
|
push :tag_or_block
|
18
18
|
end
|
19
19
|
|
20
|
-
rule %r/(\{\{)(\s*)/ do
|
20
|
+
rule %r/(\{\{-?)(\s*)/ do
|
21
21
|
groups Punctuation, Text::Whitespace
|
22
22
|
push :output
|
23
23
|
end
|
@@ -27,78 +27,70 @@ module Rouge
|
|
27
27
|
|
28
28
|
state :tag_or_block do
|
29
29
|
# builtin logic blocks
|
30
|
-
rule %r/(if|unless|
|
30
|
+
rule %r/(if|elsif|unless|case)\b/, Keyword::Reserved, :condition
|
31
|
+
rule %r/(when)\b/, Keyword::Reserved, :when
|
31
32
|
|
32
|
-
rule %r/(
|
33
|
-
groups Keyword::Reserved, Text::Whitespace
|
34
|
-
push :when
|
35
|
-
end
|
36
|
-
|
37
|
-
rule %r/(else)(\s*)(%\})/ do
|
33
|
+
rule %r/(else)(\s*)(-?%\})/ do
|
38
34
|
groups Keyword::Reserved, Text::Whitespace, Punctuation
|
39
35
|
pop!
|
40
36
|
end
|
41
37
|
|
42
38
|
# other builtin blocks
|
43
|
-
rule %r/(capture)(\s+)([^\s%]+)(\s*)(
|
44
|
-
groups Name::Tag, Text::Whitespace, Name::
|
39
|
+
rule %r/(capture|(?:in|de)crement)(\s+)([^\s%]+)(\s*)(-?%\})/ do
|
40
|
+
groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace, Punctuation
|
45
41
|
pop!
|
46
42
|
end
|
47
43
|
|
48
|
-
rule %r/(comment)(\s*)(
|
44
|
+
rule %r/(comment)(\s*)(-?%\})/ do
|
49
45
|
groups Name::Tag, Text::Whitespace, Punctuation
|
50
46
|
push :comment
|
51
47
|
end
|
52
48
|
|
53
|
-
rule %r/(raw)(\s*)(
|
49
|
+
rule %r/(raw)(\s*)(-?%\})/ do
|
54
50
|
groups Name::Tag, Text::Whitespace, Punctuation
|
55
51
|
push :raw
|
56
52
|
end
|
57
53
|
|
58
|
-
rule %r/assign/, Name::Tag, :assign
|
59
|
-
rule %r/include/, Name::Tag, :include
|
60
|
-
|
61
54
|
# end of block
|
62
|
-
rule %r/(end(?:
|
55
|
+
rule %r/(end(?:if|unless|case))(\s*)(-?%\})/ do
|
63
56
|
groups Keyword::Reserved, Text::Whitespace, Punctuation
|
64
57
|
pop!
|
65
58
|
end
|
66
59
|
|
67
|
-
rule %r/(end(?:[^\s%]+))(\s*)(
|
60
|
+
rule %r/(end(?:[^\s%]+))(\s*)(-?%\})/ do
|
68
61
|
groups Name::Tag, Text::Whitespace, Punctuation
|
69
62
|
pop!
|
70
63
|
end
|
71
64
|
|
72
65
|
# builtin tags
|
73
|
-
rule %r/(
|
74
|
-
|
75
|
-
token Text::Whitespace, m[2]
|
66
|
+
rule %r/(assign|echo)\b/, Name::Tag, :assign
|
67
|
+
rule %r/(include|render)\b/, Name::Tag, :include
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
rule %r/(cycle)(\s+)(?:([^\s:]*)(\s*)(:))?(\s*)/ do |m|
|
70
|
+
token_class = case m[3]
|
71
|
+
when %r/'[^']*'/ then Str::Single
|
72
|
+
when %r/"[^"]*"/ then Str::Double
|
73
|
+
else
|
74
|
+
Name::Attribute
|
75
|
+
end
|
84
76
|
|
85
|
-
|
86
|
-
|
77
|
+
groups Name::Tag, Text::Whitespace, token_class,
|
78
|
+
Text::Whitespace, Punctuation, Text::Whitespace
|
87
79
|
|
88
80
|
push :variable_tag_markup
|
89
81
|
end
|
90
82
|
|
91
83
|
# iteration
|
92
84
|
rule %r/
|
93
|
-
(for)(\s+)
|
85
|
+
(for|tablerow)(\s+)
|
94
86
|
([\w-]+)(\s+)
|
95
87
|
(in)(\s+)
|
96
88
|
(
|
97
|
-
(?: [^\s
|
89
|
+
(?: [^\s%,\|'"] | (?:"[^"]*"|'[^']*') )+
|
98
90
|
)(\s*)
|
99
91
|
/x do |m|
|
100
92
|
groups Name::Tag, Text::Whitespace, Name::Variable, Text::Whitespace,
|
101
|
-
|
93
|
+
Name::Tag, Text::Whitespace
|
102
94
|
|
103
95
|
token_class = case m[7]
|
104
96
|
when %r/'[^']*'/ then Str::Single
|
@@ -119,105 +111,76 @@ module Rouge
|
|
119
111
|
end
|
120
112
|
|
121
113
|
state :output do
|
122
|
-
|
123
|
-
|
114
|
+
rule %r/(\|)(\s*)([a-zA-Z_][^\s}\|:]*)/ do
|
115
|
+
groups Punctuation, Text::Whitespace, Name::Function
|
116
|
+
push :filters
|
117
|
+
end
|
124
118
|
|
125
|
-
|
126
|
-
|
119
|
+
mixin :end_of_tag
|
120
|
+
mixin :generic
|
127
121
|
end
|
128
122
|
|
129
123
|
state :filters do
|
130
|
-
|
131
|
-
|
132
|
-
rule(/\}\}/) { token Punctuation; reset_stack }
|
133
|
-
|
134
|
-
rule %r/([^\s\|:]+)(:?)(\s*)/ do
|
135
|
-
groups Name::Function, Punctuation, Text::Whitespace
|
136
|
-
push :filter_markup
|
124
|
+
rule %r/(\|)(\s*)([a-zA-Z_][^\s%}\|:]*)/ do
|
125
|
+
groups Punctuation, Text::Whitespace, Name::Function
|
137
126
|
end
|
138
|
-
end
|
139
|
-
|
140
|
-
state :filter_markup do
|
141
|
-
rule %r/\|/, Punctuation, :pop!
|
142
127
|
|
143
128
|
mixin :end_of_tag
|
144
129
|
mixin :end_of_block
|
145
|
-
mixin :
|
130
|
+
mixin :variable_param_markup
|
146
131
|
end
|
147
132
|
|
148
133
|
state :condition do
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
rule %r/([=!><]=?)/, Operator
|
153
|
-
|
154
|
-
rule %r/\b(?:(!)|(not\b))/ do
|
155
|
-
groups Operator, Operator::Word
|
156
|
-
end
|
157
|
-
|
158
|
-
rule %r/(contains)/, Operator::Word
|
134
|
+
rule %r/([=!]=|[<>]=?)/, Operator
|
135
|
+
rule %r/(and|or|contains)\b/, Operator::Word
|
159
136
|
|
137
|
+
mixin :end_of_block
|
160
138
|
mixin :generic
|
161
|
-
mixin :whitespace
|
162
139
|
end
|
163
140
|
|
164
141
|
state :when do
|
165
142
|
mixin :end_of_block
|
166
|
-
mixin :whitespace
|
167
143
|
mixin :generic
|
168
144
|
end
|
169
145
|
|
170
|
-
state :operator do
|
171
|
-
rule %r/(\s*)((?:=|!|>|<)=?)(\s*)/ do
|
172
|
-
groups Text::Whitespace, Operator, Text::Whitespace
|
173
|
-
pop!
|
174
|
-
end
|
175
|
-
|
176
|
-
rule %r/(\s*)(\bcontains\b)(\s*)/ do
|
177
|
-
groups Text::Whitespace, Operator::Word, Text::Whitespace
|
178
|
-
pop!
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
146
|
state :end_of_tag do
|
183
|
-
rule(
|
147
|
+
rule(/-?\}\}/) { token Punctuation; reset_stack }
|
184
148
|
end
|
185
149
|
|
186
150
|
state :end_of_block do
|
187
|
-
rule(
|
151
|
+
rule(/-?%\}/) { token Punctuation; reset_stack }
|
188
152
|
end
|
189
153
|
|
190
154
|
# states for unknown markup
|
191
155
|
state :param_markup do
|
192
156
|
mixin :whitespace
|
157
|
+
mixin :keyword
|
193
158
|
mixin :string
|
159
|
+
mixin :number
|
194
160
|
|
195
161
|
rule %r/([^\s=:]+)(\s*)(=|:)/ do
|
196
162
|
groups Name::Attribute, Text::Whitespace, Operator
|
197
163
|
end
|
198
164
|
|
199
|
-
rule %r/
|
200
|
-
groups Punctuation, Text::Whitespace, Text, Text::Whitespace, Punctuation
|
201
|
-
end
|
202
|
-
|
203
|
-
mixin :number
|
204
|
-
mixin :keyword
|
205
|
-
|
206
|
-
rule %r/,/, Punctuation
|
165
|
+
rule %r/[,:]/, Punctuation
|
207
166
|
end
|
208
167
|
|
209
168
|
state :default_param_markup do
|
210
169
|
mixin :param_markup
|
211
|
-
|
170
|
+
|
171
|
+
rule %r/\S+/, Text
|
212
172
|
end
|
213
173
|
|
214
174
|
state :variable_param_markup do
|
215
175
|
mixin :param_markup
|
216
176
|
mixin :variable
|
217
|
-
|
177
|
+
|
178
|
+
rule %r/\S+/, Text
|
218
179
|
end
|
219
180
|
|
220
181
|
state :tag_markup do
|
182
|
+
rule %r/(reversed)\b/, Name::Attribute
|
183
|
+
|
221
184
|
mixin :end_of_block
|
222
185
|
mixin :default_param_markup
|
223
186
|
end
|
@@ -229,12 +192,14 @@ module Rouge
|
|
229
192
|
|
230
193
|
# states for different values types
|
231
194
|
state :keyword do
|
232
|
-
rule %r
|
195
|
+
rule %r/(false|true|nil)\b/, Keyword::Constant
|
233
196
|
end
|
234
197
|
|
235
198
|
state :variable do
|
236
|
-
rule %r
|
237
|
-
rule %r
|
199
|
+
rule %r/(empty|blank|forloop\.[^\s%}\|:]+)\b/, Name::Builtin
|
200
|
+
rule %r/\.(?=\w)|\[|\]/, Punctuation
|
201
|
+
rule %r/(first|last|size)\b/, Name::Function
|
202
|
+
rule %r/[a-zA-Z_][\w-]*\??/, Name::Variable
|
238
203
|
end
|
239
204
|
|
240
205
|
state :string do
|
@@ -243,21 +208,17 @@ module Rouge
|
|
243
208
|
end
|
244
209
|
|
245
210
|
state :number do
|
211
|
+
rule %r/-/, Operator
|
246
212
|
rule %r/\d+\.\d+/, Num::Float
|
247
213
|
rule %r/\d+/, Num::Integer
|
248
214
|
end
|
249
215
|
|
250
|
-
state :array_index do
|
251
|
-
rule %r/\[/, Punctuation
|
252
|
-
rule %r/\]/, Punctuation
|
253
|
-
end
|
254
|
-
|
255
216
|
state :generic do
|
256
|
-
mixin :
|
217
|
+
mixin :whitespace
|
257
218
|
mixin :keyword
|
258
219
|
mixin :string
|
259
|
-
mixin :variable
|
260
220
|
mixin :number
|
221
|
+
mixin :variable
|
261
222
|
end
|
262
223
|
|
263
224
|
state :whitespace do
|
@@ -265,18 +226,20 @@ module Rouge
|
|
265
226
|
end
|
266
227
|
|
267
228
|
state :comment do
|
268
|
-
rule %r/
|
229
|
+
rule %r/[^\{]+/, Comment
|
230
|
+
|
231
|
+
rule %r/(\{%-?)(\s*)(endcomment)(\s*)(-?%\})/ do
|
269
232
|
groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
|
270
233
|
reset_stack
|
271
234
|
end
|
272
235
|
|
273
|
-
rule %r
|
236
|
+
rule %r/\{/, Comment
|
274
237
|
end
|
275
238
|
|
276
239
|
state :raw do
|
277
240
|
rule %r/[^\{]+/, Text
|
278
241
|
|
279
|
-
rule %r/(\{
|
242
|
+
rule %r/(\{%-?)(\s*)(endraw)(\s*)(-?%\})/ do
|
280
243
|
groups Punctuation, Text::Whitespace, Name::Tag, Text::Whitespace, Punctuation
|
281
244
|
reset_stack
|
282
245
|
end
|
@@ -285,27 +248,38 @@ module Rouge
|
|
285
248
|
end
|
286
249
|
|
287
250
|
state :assign do
|
288
|
-
|
289
|
-
mixin :end_of_block
|
251
|
+
rule %r/=/, Operator
|
290
252
|
|
291
|
-
rule %r/(\s*)(
|
292
|
-
groups Text::Whitespace,
|
253
|
+
rule %r/(\|)(\s*)([a-zA-Z_][^\s%\|:]*)/ do
|
254
|
+
groups Punctuation, Text::Whitespace, Name::Function
|
255
|
+
push :filters
|
293
256
|
end
|
294
257
|
|
295
|
-
|
296
|
-
|
258
|
+
mixin :end_of_block
|
297
259
|
mixin :generic
|
298
260
|
end
|
299
261
|
|
300
262
|
state :include do
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
groups Name::Attribute, Punctuation, Name::Attribute
|
263
|
+
rule %r/(\{\{-?)(\s*)/ do
|
264
|
+
groups Punctuation, Text::Whitespace
|
265
|
+
push :output_embed
|
305
266
|
end
|
306
267
|
|
268
|
+
rule %r/(with|for)\b/, Name::Tag
|
269
|
+
rule %r/[^\s\.]+(\.[^\s\.]+)+\b/, Name::Other
|
270
|
+
|
307
271
|
mixin :variable_tag_markup
|
308
272
|
end
|
273
|
+
|
274
|
+
state :output_embed do
|
275
|
+
rule %r/(\|)(\s*)([a-zA-Z_][^\s}\|:]*)/ do
|
276
|
+
groups Punctuation, Text::Whitespace, Name::Function
|
277
|
+
end
|
278
|
+
|
279
|
+
rule %r/-?\}\}/, Punctuation, :pop!
|
280
|
+
|
281
|
+
mixin :variable_param_markup
|
282
|
+
end
|
309
283
|
end
|
310
284
|
end
|
311
285
|
end
|