rouge 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/bin/rougify +1 -1
- data/lib/rouge/demos/{text → plaintext} +0 -0
- data/lib/rouge/formatters/html.rb +13 -8
- data/lib/rouge/formatters/terminal256.rb +15 -11
- data/lib/rouge/lexer.rb +3 -1
- data/lib/rouge/lexers/c.rb +65 -55
- data/lib/rouge/lexers/clojure.rb +19 -19
- data/lib/rouge/lexers/coffeescript.rb +42 -42
- data/lib/rouge/lexers/common_lisp.rb +49 -48
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/cpp.rb +48 -48
- data/lib/rouge/lexers/csharp.rb +25 -25
- data/lib/rouge/lexers/css.rb +32 -33
- data/lib/rouge/lexers/diff.rb +8 -8
- data/lib/rouge/lexers/elixir.rb +30 -30
- data/lib/rouge/lexers/erb.rb +5 -5
- data/lib/rouge/lexers/erlang.rb +38 -38
- data/lib/rouge/lexers/factor.rb +56 -56
- data/lib/rouge/lexers/gherkin.rb +27 -27
- data/lib/rouge/lexers/go.rb +21 -21
- data/lib/rouge/lexers/groovy.rb +32 -32
- data/lib/rouge/lexers/haml.rb +35 -35
- data/lib/rouge/lexers/handlebars.rb +27 -27
- data/lib/rouge/lexers/haskell.rb +78 -79
- data/lib/rouge/lexers/html.rb +28 -28
- data/lib/rouge/lexers/http.rb +13 -13
- data/lib/rouge/lexers/ini.rb +13 -13
- data/lib/rouge/lexers/io.rb +19 -19
- data/lib/rouge/lexers/java.rb +29 -29
- data/lib/rouge/lexers/javascript.rb +49 -52
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +14 -14
- data/lib/rouge/lexers/lua.rb +33 -33
- data/lib/rouge/lexers/make.rb +26 -26
- data/lib/rouge/lexers/markdown.rb +49 -49
- data/lib/rouge/lexers/nginx.rb +19 -19
- data/lib/rouge/lexers/perl.rb +53 -54
- data/lib/rouge/lexers/php.rb +42 -43
- data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
- data/lib/rouge/lexers/prolog.rb +19 -19
- data/lib/rouge/lexers/puppet.rb +40 -40
- data/lib/rouge/lexers/python.rb +63 -63
- data/lib/rouge/lexers/r.rb +15 -15
- data/lib/rouge/lexers/racket.rb +29 -29
- data/lib/rouge/lexers/ruby.rb +94 -97
- data/lib/rouge/lexers/rust.rb +37 -37
- data/lib/rouge/lexers/sass.rb +15 -15
- data/lib/rouge/lexers/sass/common.rb +144 -136
- data/lib/rouge/lexers/scheme.rb +25 -25
- data/lib/rouge/lexers/scss.rb +7 -7
- data/lib/rouge/lexers/sed.rb +39 -39
- data/lib/rouge/lexers/shell.rb +45 -45
- data/lib/rouge/lexers/smalltalk.rb +36 -36
- data/lib/rouge/lexers/sql.rb +27 -27
- data/lib/rouge/lexers/tcl.rb +34 -34
- data/lib/rouge/lexers/tex.rb +24 -24
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/viml.rb +19 -19
- data/lib/rouge/lexers/xml.rb +16 -16
- data/lib/rouge/lexers/yaml.rb +78 -81
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/regex_lexer.rb +31 -14
- data/lib/rouge/template_lexer.rb +1 -1
- data/lib/rouge/theme.rb +12 -10
- data/lib/rouge/themes/thankful_eyes.rb +43 -43
- data/lib/rouge/token.rb +145 -148
- data/lib/rouge/version.rb +1 -1
- metadata +4 -4
data/lib/rouge/lexers/gherkin.rb
CHANGED
@@ -36,15 +36,15 @@ module Rouge
|
|
36
36
|
rest_of_line = /.*?(?=[#\n])/
|
37
37
|
|
38
38
|
state :basic do
|
39
|
-
rule %r(#.*$),
|
40
|
-
rule /[ \r\t]+/,
|
39
|
+
rule %r(#.*$), Comment
|
40
|
+
rule /[ \r\t]+/, Text
|
41
41
|
end
|
42
42
|
|
43
43
|
state :root do
|
44
44
|
mixin :basic
|
45
|
-
rule %r(\n),
|
46
|
-
rule %r(""".*?""")m,
|
47
|
-
rule %r(@[^\s@]+),
|
45
|
+
rule %r(\n), Text
|
46
|
+
rule %r(""".*?""")m, Str
|
47
|
+
rule %r(@[^\s@]+), Name::Tag
|
48
48
|
mixin :has_table
|
49
49
|
mixin :has_examples
|
50
50
|
end
|
@@ -55,23 +55,23 @@ module Rouge
|
|
55
55
|
|
56
56
|
keyword = m[1]
|
57
57
|
if self.class.keywords[:element].include? keyword
|
58
|
-
group
|
58
|
+
group Keyword::Namespace; push :description
|
59
59
|
elsif self.class.keywords[:feature].include? keyword
|
60
|
-
group
|
60
|
+
group Keyword::Declaration; push :feature_description
|
61
61
|
elsif self.class.keywords[:examples].include? keyword
|
62
|
-
group
|
62
|
+
group Name::Namespace; push :example_description
|
63
63
|
else
|
64
|
-
group
|
64
|
+
group Error
|
65
65
|
end
|
66
66
|
|
67
|
-
group
|
67
|
+
group Punctuation
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
state :has_examples do
|
72
72
|
mixin :has_scenarios
|
73
|
-
rule Gherkin.step_regex,
|
74
|
-
token
|
73
|
+
rule Gherkin.step_regex, Name::Function do
|
74
|
+
token Name::Function
|
75
75
|
reset_stack; push :step
|
76
76
|
end
|
77
77
|
end
|
@@ -81,10 +81,10 @@ module Rouge
|
|
81
81
|
end
|
82
82
|
|
83
83
|
state :table_header do
|
84
|
-
rule /[^|\s]+/,
|
84
|
+
rule /[^|\s]+/, Name::Variable
|
85
85
|
rule /\n/ do
|
86
|
-
token
|
87
|
-
|
86
|
+
token Text
|
87
|
+
goto :table
|
88
88
|
end
|
89
89
|
mixin :table
|
90
90
|
end
|
@@ -92,37 +92,37 @@ module Rouge
|
|
92
92
|
state :table do
|
93
93
|
rule(/^(?=\s*[^\s|])/) { reset_stack }
|
94
94
|
mixin :basic
|
95
|
-
rule /[|]/,
|
96
|
-
rule /[^|\s]+/,
|
95
|
+
rule /[|]/, Punctuation
|
96
|
+
rule /[^|\s]+/, Name
|
97
97
|
end
|
98
98
|
|
99
99
|
state :description do
|
100
100
|
mixin :basic
|
101
101
|
mixin :has_examples
|
102
|
-
rule /\n/,
|
103
|
-
rule rest_of_line,
|
102
|
+
rule /\n/, Text
|
103
|
+
rule rest_of_line, Text
|
104
104
|
end
|
105
105
|
|
106
106
|
state :feature_description do
|
107
107
|
mixin :basic
|
108
108
|
mixin :has_scenarios
|
109
|
-
rule /\n/,
|
110
|
-
rule rest_of_line,
|
109
|
+
rule /\n/, Text
|
110
|
+
rule rest_of_line, Text
|
111
111
|
end
|
112
112
|
|
113
113
|
state :example_description do
|
114
114
|
mixin :basic
|
115
115
|
mixin :has_table
|
116
|
-
rule /\n/,
|
117
|
-
rule rest_of_line,
|
116
|
+
rule /\n/, Text
|
117
|
+
rule rest_of_line, Text
|
118
118
|
end
|
119
119
|
|
120
120
|
state :step do
|
121
121
|
mixin :basic
|
122
|
-
rule /<.*?>/,
|
123
|
-
rule /".*?"/,
|
124
|
-
rule /\S+/,
|
125
|
-
rule rest_of_line,
|
122
|
+
rule /<.*?>/, Name::Variable
|
123
|
+
rule /".*?"/, Str
|
124
|
+
rule /\S+/, Text
|
125
|
+
rule rest_of_line, Text, :pop!
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
data/lib/rouge/lexers/go.rb
CHANGED
@@ -137,38 +137,38 @@ module Rouge
|
|
137
137
|
)\b/x
|
138
138
|
|
139
139
|
state :simple_tokens do
|
140
|
-
rule(COMMENT,
|
141
|
-
rule(KEYWORD,
|
142
|
-
rule(PREDECLARED_TYPES,
|
143
|
-
rule(PREDECLARED_FUNCTIONS,
|
144
|
-
rule(PREDECLARED_CONSTANTS,
|
145
|
-
rule(IMAGINARY_LIT,
|
146
|
-
rule(FLOAT_LIT,
|
147
|
-
rule(INT_LIT,
|
148
|
-
rule(CHAR_LIT,
|
149
|
-
rule(OPERATOR,
|
150
|
-
rule(SEPARATOR,
|
151
|
-
rule(IDENTIFIER,
|
152
|
-
rule(WHITE_SPACE,
|
140
|
+
rule(COMMENT, Comment)
|
141
|
+
rule(KEYWORD, Keyword)
|
142
|
+
rule(PREDECLARED_TYPES, Keyword::Type)
|
143
|
+
rule(PREDECLARED_FUNCTIONS, Name::Builtin)
|
144
|
+
rule(PREDECLARED_CONSTANTS, Name::Constant)
|
145
|
+
rule(IMAGINARY_LIT, Num)
|
146
|
+
rule(FLOAT_LIT, Num)
|
147
|
+
rule(INT_LIT, Num)
|
148
|
+
rule(CHAR_LIT, Str::Char)
|
149
|
+
rule(OPERATOR, Operator)
|
150
|
+
rule(SEPARATOR, Punctuation)
|
151
|
+
rule(IDENTIFIER, Name)
|
152
|
+
rule(WHITE_SPACE, Other)
|
153
153
|
end
|
154
154
|
|
155
155
|
state :root do
|
156
156
|
mixin :simple_tokens
|
157
157
|
|
158
|
-
rule(/`/,
|
159
|
-
rule(/"/,
|
158
|
+
rule(/`/, Str, :raw_string)
|
159
|
+
rule(/"/, Str, :interpreted_string)
|
160
160
|
end
|
161
161
|
|
162
162
|
state :interpreted_string do
|
163
|
-
rule(ESCAPE_SEQUENCE,
|
164
|
-
rule(/\\./,
|
165
|
-
rule(/"/,
|
166
|
-
rule(
|
163
|
+
rule(ESCAPE_SEQUENCE, Str::Escape)
|
164
|
+
rule(/\\./, Error)
|
165
|
+
rule(/"/, Str, :pop!)
|
166
|
+
rule(/[^"\\]+/, Str)
|
167
167
|
end
|
168
168
|
|
169
169
|
state :raw_string do
|
170
|
-
rule(/`/,
|
171
|
-
rule(
|
170
|
+
rule(/`/, Str, :pop!)
|
171
|
+
rule(/[^`]+/m, Str)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
data/lib/rouge/lexers/groovy.rb
CHANGED
@@ -40,62 +40,62 @@ module Rouge
|
|
40
40
|
(\s*) (\() # signature start
|
41
41
|
)x do |m|
|
42
42
|
delegate self.clone, m[1]
|
43
|
-
token
|
44
|
-
token
|
45
|
-
token
|
43
|
+
token Name::Function, m[2]
|
44
|
+
token Text, m[3]
|
45
|
+
token Operator, m[4]
|
46
46
|
end
|
47
47
|
|
48
48
|
# whitespace
|
49
|
-
rule /[^\S\n]+/,
|
50
|
-
rule %r(//.*?\n),
|
51
|
-
rule %r(/[*].*?[*]/),
|
52
|
-
rule /@\w[\w\d.]*/,
|
53
|
-
rule /(class|interface)\b/,
|
54
|
-
rule /package\b/,
|
55
|
-
rule /import\b/,
|
49
|
+
rule /[^\S\n]+/, Text
|
50
|
+
rule %r(//.*?\n), Comment::Single
|
51
|
+
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
52
|
+
rule /@\w[\w\d.]*/, Name::Decorator
|
53
|
+
rule /(class|interface)\b/, Keyword::Declaration, :class
|
54
|
+
rule /package\b/, Keyword::Namespace, :import
|
55
|
+
rule /import\b/, Keyword::Namespace, :import
|
56
56
|
|
57
|
-
rule /"(\\\\|\\"|[^"])*"/,
|
58
|
-
rule /'(\\\\|\\'|[^'])*'/,
|
59
|
-
rule %r(\$/((?!/\$).)*/\$),
|
60
|
-
rule %r(/(\\\\|\\"|[^/])*/),
|
61
|
-
rule /'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'/,
|
57
|
+
rule /"(\\\\|\\"|[^"])*"/, Str::Double
|
58
|
+
rule /'(\\\\|\\'|[^'])*'/, Str::Single
|
59
|
+
rule %r(\$/((?!/\$).)*/\$), Str
|
60
|
+
rule %r(/(\\\\|\\"|[^/])*/), Str
|
61
|
+
rule /'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'/, Str::Char
|
62
62
|
rule /(\.)([a-zA-Z_][a-zA-Z0-9_]*)/ do
|
63
|
-
group
|
64
|
-
group
|
63
|
+
group Operator
|
64
|
+
group Name::Attribute
|
65
65
|
end
|
66
66
|
|
67
|
-
rule /[a-zA-Z_][a-zA-Z0-9_]*:/,
|
67
|
+
rule /[a-zA-Z_][a-zA-Z0-9_]*:/, Name::Label
|
68
68
|
rule /[a-zA-Z_\$][a-zA-Z0-9_]*/ do |m|
|
69
69
|
if self.class.keywords.include? m[0]
|
70
|
-
token
|
70
|
+
token Keyword
|
71
71
|
elsif self.class.declarations.include? m[0]
|
72
|
-
token
|
72
|
+
token Keyword::Declaration
|
73
73
|
elsif self.class.types.include? m[0]
|
74
|
-
token
|
74
|
+
token Keyword::Type
|
75
75
|
elsif self.class.constants.include? m[0]
|
76
|
-
token
|
76
|
+
token Keyword::Constant
|
77
77
|
else
|
78
|
-
token
|
78
|
+
token Name
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
rule %r([~^*!%&\[\](){}<>\|+=:;,./?-]),
|
82
|
+
rule %r([~^*!%&\[\](){}<>\|+=:;,./?-]), Operator
|
83
83
|
|
84
84
|
# numbers
|
85
|
-
rule /\d+\.\d+([eE]\d+)?[fd]?/,
|
86
|
-
rule /0x[0-9a-f]+/,
|
87
|
-
rule /[0-9]+L?/,
|
88
|
-
rule /\n/,
|
85
|
+
rule /\d+\.\d+([eE]\d+)?[fd]?/, Num::Float
|
86
|
+
rule /0x[0-9a-f]+/, Num::Hex
|
87
|
+
rule /[0-9]+L?/, Num::Integer
|
88
|
+
rule /\n/, Text
|
89
89
|
end
|
90
90
|
|
91
91
|
state :class do
|
92
|
-
rule /\s+/,
|
93
|
-
rule /\w[\w\d]*/,
|
92
|
+
rule /\s+/, Text
|
93
|
+
rule /\w[\w\d]*/, Name::Class, :pop!
|
94
94
|
end
|
95
95
|
|
96
96
|
state :import do
|
97
|
-
rule /\s+/,
|
98
|
-
rule /[\w\d.]+[*]?/,
|
97
|
+
rule /\s+/, Text
|
98
|
+
rule /[\w\d.]+[*]?/, Name::Namespace, :pop!
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
data/lib/rouge/lexers/haml.rb
CHANGED
@@ -71,42 +71,42 @@ module Rouge
|
|
71
71
|
comma_dot = /,\s*\n|#{dot}/
|
72
72
|
|
73
73
|
state :root do
|
74
|
-
rule /\s*\n/,
|
75
|
-
rule(/\s*/) { |m| token
|
74
|
+
rule /\s*\n/, Text
|
75
|
+
rule(/\s*/) { |m| token Text; indentation(m[0]) }
|
76
76
|
end
|
77
77
|
|
78
78
|
state :content do
|
79
79
|
mixin :css
|
80
|
-
rule(/%#{identifier}/) { token
|
81
|
-
rule /!!!#{dot}*\n/,
|
80
|
+
rule(/%#{identifier}/) { token Name::Tag; goto :tag }
|
81
|
+
rule /!!!#{dot}*\n/, Name::Namespace, :pop!
|
82
82
|
rule %r(
|
83
83
|
(/) (\[#{dot}*?\]) (#{dot}*\n)
|
84
84
|
)x do
|
85
|
-
group
|
85
|
+
group Comment; group Comment::Special; group Comment
|
86
86
|
pop!
|
87
87
|
end
|
88
88
|
|
89
89
|
rule %r(/#{dot}*\n) do
|
90
|
-
token
|
90
|
+
token Comment
|
91
91
|
pop!
|
92
92
|
starts_block :html_comment_block
|
93
93
|
end
|
94
94
|
|
95
95
|
rule /-##{dot}*\n/ do
|
96
|
-
token
|
96
|
+
token Comment
|
97
97
|
pop!
|
98
98
|
starts_block :haml_comment_block
|
99
99
|
end
|
100
100
|
|
101
101
|
rule /-/ do
|
102
|
-
token
|
102
|
+
token Punctuation
|
103
103
|
reset_stack
|
104
104
|
push :ruby_line
|
105
105
|
end
|
106
106
|
|
107
107
|
# filters
|
108
108
|
rule /:(#{dot}*)\n/ do |m|
|
109
|
-
token
|
109
|
+
token Name::Decorator
|
110
110
|
pop!
|
111
111
|
starts_block :filter_block
|
112
112
|
|
@@ -122,19 +122,19 @@ module Rouge
|
|
122
122
|
end
|
123
123
|
|
124
124
|
state :css do
|
125
|
-
rule(/\.#{identifier}/) { token
|
126
|
-
rule(/##{identifier}/) { token
|
125
|
+
rule(/\.#{identifier}/) { token Name::Class; goto :tag }
|
126
|
+
rule(/##{identifier}/) { token Name::Function; goto :tag }
|
127
127
|
end
|
128
128
|
|
129
129
|
state :tag do
|
130
130
|
mixin :css
|
131
131
|
rule(/\{#{comma_dot}*?\}/) { delegate ruby }
|
132
132
|
rule(/\[#{dot}*?\]/) { delegate ruby }
|
133
|
-
rule /\(/,
|
134
|
-
rule /\s*\n/,
|
133
|
+
rule /\(/, Punctuation, :html_attributes
|
134
|
+
rule /\s*\n/, Text, :pop!
|
135
135
|
|
136
136
|
# whitespace chompers
|
137
|
-
rule /[<>]{1,2}(?=[ \t=])/,
|
137
|
+
rule /[<>]{1,2}(?=[ \t=])/, Punctuation
|
138
138
|
|
139
139
|
mixin :eval_or_plain
|
140
140
|
end
|
@@ -142,13 +142,13 @@ module Rouge
|
|
142
142
|
state :plain do
|
143
143
|
rule(/([^#\n]|#[^{\n]|(\\\\)*\\#\{)+/) { delegate html }
|
144
144
|
mixin :interpolation
|
145
|
-
rule(/\n/) { token
|
145
|
+
rule(/\n/) { token Text; reset_stack }
|
146
146
|
end
|
147
147
|
|
148
148
|
state :eval_or_plain do
|
149
|
-
rule /[&!]?==/,
|
149
|
+
rule /[&!]?==/, Punctuation, :plain
|
150
150
|
rule /[&!]?[=!]/ do
|
151
|
-
token
|
151
|
+
token Punctuation
|
152
152
|
reset_stack
|
153
153
|
push :ruby_line
|
154
154
|
end
|
@@ -157,35 +157,35 @@ module Rouge
|
|
157
157
|
end
|
158
158
|
|
159
159
|
state :ruby_line do
|
160
|
-
rule /\n/,
|
160
|
+
rule /\n/, Text, :pop!
|
161
161
|
rule(/,[ \t]*\n/) { delegate ruby }
|
162
|
-
rule /[ ]\|[ \t]*\n/,
|
162
|
+
rule /[ ]\|[ \t]*\n/, Str::Escape
|
163
163
|
rule(/.*?(?=(,$| \|)?[ \t]*$)/) { delegate ruby }
|
164
164
|
end
|
165
165
|
|
166
166
|
state :html_attributes do
|
167
|
-
rule /\s+/,
|
168
|
-
rule /#{identifier}\s*=/,
|
169
|
-
rule identifier,
|
170
|
-
rule /\)/,
|
167
|
+
rule /\s+/, Text
|
168
|
+
rule /#{identifier}\s*=/, Name::Attribute, :html_attribute_value
|
169
|
+
rule identifier, Name::Attribute
|
170
|
+
rule /\)/, Text, :pop!
|
171
171
|
end
|
172
172
|
|
173
173
|
state :html_attribute_value do
|
174
|
-
rule /\s+/,
|
175
|
-
rule ruby_var,
|
176
|
-
rule /@#{ruby_var}/,
|
177
|
-
rule /\$#{ruby_var}/,
|
178
|
-
rule /'(\\\\|\\'|[^'\n])*'/,
|
179
|
-
rule /"(\\\\|\\"|[^"\n])*"/,
|
174
|
+
rule /\s+/, Text
|
175
|
+
rule ruby_var, Name::Variable, :pop!
|
176
|
+
rule /@#{ruby_var}/, Name::Variable::Instance, :pop!
|
177
|
+
rule /\$#{ruby_var}/, Name::Variable::Global, :pop!
|
178
|
+
rule /'(\\\\|\\'|[^'\n])*'/, Str, :pop!
|
179
|
+
rule /"(\\\\|\\"|[^"\n])*"/, Str, :pop!
|
180
180
|
end
|
181
181
|
|
182
182
|
state :html_comment_block do
|
183
|
-
rule /#{dot}+/,
|
183
|
+
rule /#{dot}+/, Comment
|
184
184
|
mixin :indented_block
|
185
185
|
end
|
186
186
|
|
187
187
|
state :haml_comment_block do
|
188
|
-
rule /#{dot}+/,
|
188
|
+
rule /#{dot}+/, Comment::Preproc
|
189
189
|
mixin :indented_block
|
190
190
|
end
|
191
191
|
|
@@ -194,7 +194,7 @@ module Rouge
|
|
194
194
|
if @filter_lexer
|
195
195
|
delegate @filter_lexer
|
196
196
|
else
|
197
|
-
token
|
197
|
+
token Name::Decorator
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
@@ -204,14 +204,14 @@ module Rouge
|
|
204
204
|
|
205
205
|
state :interpolation do
|
206
206
|
rule /(#\{)(#{dot}*?)(\})/ do |m|
|
207
|
-
token
|
207
|
+
token Str::Interpol, m[1]
|
208
208
|
delegate ruby, m[2]
|
209
|
-
token
|
209
|
+
token Str::Interpol, m[3]
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
213
|
state :indented_block do
|
214
|
-
rule(/\n/) { token
|
214
|
+
rule(/\n/) { token Text; reset_stack }
|
215
215
|
end
|
216
216
|
end
|
217
217
|
end
|
@@ -14,11 +14,11 @@ module Rouge
|
|
14
14
|
rule(/\\{+/) { delegate parent }
|
15
15
|
|
16
16
|
# block comments
|
17
|
-
rule /{{!--/,
|
18
|
-
rule /{{!.*?}}/,
|
17
|
+
rule /{{!--/, Comment, :comment
|
18
|
+
rule /{{!.*?}}/, Comment
|
19
19
|
|
20
20
|
rule /{{{?/ do
|
21
|
-
token
|
21
|
+
token Keyword
|
22
22
|
push :stache
|
23
23
|
push :open_sym
|
24
24
|
end
|
@@ -31,44 +31,44 @@ module Rouge
|
|
31
31
|
end
|
32
32
|
|
33
33
|
state :comment do
|
34
|
-
rule(/{{/) { token
|
35
|
-
rule(/}}/) { token
|
36
|
-
rule(/[^{}]+/m) { token
|
37
|
-
rule(/[{}]/) { token
|
34
|
+
rule(/{{/) { token Comment; push }
|
35
|
+
rule(/}}/) { token Comment; pop! }
|
36
|
+
rule(/[^{}]+/m) { token Comment }
|
37
|
+
rule(/[{}]/) { token Comment }
|
38
38
|
end
|
39
39
|
|
40
40
|
state :stache do
|
41
|
-
rule /}}}?/,
|
42
|
-
rule /\s+/m,
|
43
|
-
rule /[=]/,
|
44
|
-
rule /[\[\]]/,
|
45
|
-
rule /[.](?=[}\s])/,
|
46
|
-
rule /[.][.]/,
|
47
|
-
rule %r([/.]),
|
48
|
-
rule /"(\\.|.)*?"/,
|
49
|
-
rule /'(\\.|.)*?'/,
|
50
|
-
rule /\d+(?=}\s)/,
|
51
|
-
rule /(true|false)(?=[}\s])/,
|
52
|
-
rule /else(?=[}\s])/,
|
53
|
-
rule /this(?=[}\s])/,
|
54
|
-
rule /@#{id}/,
|
55
|
-
rule id,
|
41
|
+
rule /}}}?/, Keyword, :pop!
|
42
|
+
rule /\s+/m, Text
|
43
|
+
rule /[=]/, Operator
|
44
|
+
rule /[\[\]]/, Punctuation
|
45
|
+
rule /[.](?=[}\s])/, Name::Variable
|
46
|
+
rule /[.][.]/, Name::Variable
|
47
|
+
rule %r([/.]), Punctuation
|
48
|
+
rule /"(\\.|.)*?"/, Str::Double
|
49
|
+
rule /'(\\.|.)*?'/, Str::Single
|
50
|
+
rule /\d+(?=}\s)/, Num
|
51
|
+
rule /(true|false)(?=[}\s])/, Keyword::Constant
|
52
|
+
rule /else(?=[}\s])/, Keyword
|
53
|
+
rule /this(?=[}\s])/, Name::Builtin::Pseudo
|
54
|
+
rule /@#{id}/, Name::Attribute
|
55
|
+
rule id, Name::Variable
|
56
56
|
end
|
57
57
|
|
58
58
|
state :open_sym do
|
59
59
|
rule %r([#/]) do
|
60
|
-
token
|
61
|
-
|
60
|
+
token Keyword
|
61
|
+
goto :block_name
|
62
62
|
end
|
63
63
|
|
64
|
-
rule /[>^&]/,
|
64
|
+
rule /[>^&]/, Keyword
|
65
65
|
|
66
66
|
rule(//) { pop! }
|
67
67
|
end
|
68
68
|
|
69
69
|
state :block_name do
|
70
|
-
rule /if(?=[}\s])/,
|
71
|
-
rule id,
|
70
|
+
rule /if(?=[}\s])/, Keyword
|
71
|
+
rule id, Name::Namespace, :pop!
|
72
72
|
rule(//) { pop! }
|
73
73
|
end
|
74
74
|
end
|