rouge 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge.rb +3 -0
- data/lib/rouge/cli.rb +19 -2
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/tex.rb +90 -0
- data/lib/rouge/guessers/glob_mapping.rb +1 -1
- data/lib/rouge/lexer.rb +22 -10
- data/lib/rouge/lexers/abap.rb +11 -11
- data/lib/rouge/lexers/actionscript.rb +34 -34
- data/lib/rouge/lexers/apache.rb +8 -8
- data/lib/rouge/lexers/apple_script.rb +15 -14
- data/lib/rouge/lexers/awk.rb +25 -25
- data/lib/rouge/lexers/biml.rb +4 -4
- data/lib/rouge/lexers/bpf.rb +104 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +12 -12
- data/lib/rouge/lexers/c.rb +30 -30
- data/lib/rouge/lexers/ceylon.rb +1 -29
- data/lib/rouge/lexers/cfscript.rb +26 -26
- data/lib/rouge/lexers/clojure.rb +14 -14
- data/lib/rouge/lexers/cmake.rb +14 -14
- data/lib/rouge/lexers/coffeescript.rb +30 -30
- data/lib/rouge/lexers/common_lisp.rb +36 -36
- data/lib/rouge/lexers/conf.rb +6 -6
- data/lib/rouge/lexers/coq.rb +18 -18
- data/lib/rouge/lexers/cpp.rb +8 -8
- data/lib/rouge/lexers/crystal.rb +70 -70
- data/lib/rouge/lexers/csharp.rb +28 -28
- data/lib/rouge/lexers/css.rb +23 -23
- data/lib/rouge/lexers/d.rb +59 -59
- data/lib/rouge/lexers/dart.rb +33 -33
- data/lib/rouge/lexers/digdag.rb +1 -1
- data/lib/rouge/lexers/docker.rb +10 -10
- data/lib/rouge/lexers/dot.rb +16 -16
- data/lib/rouge/lexers/eiffel.rb +20 -20
- data/lib/rouge/lexers/elixir.rb +29 -28
- data/lib/rouge/lexers/elm.rb +29 -29
- data/lib/rouge/lexers/erb.rb +4 -4
- data/lib/rouge/lexers/factor.rb +40 -40
- data/lib/rouge/lexers/fortran.rb +32 -32
- data/lib/rouge/lexers/fsharp.rb +26 -26
- data/lib/rouge/lexers/gherkin.rb +13 -13
- data/lib/rouge/lexers/glsl.rb +0 -4
- data/lib/rouge/lexers/go.rb +1 -1
- data/lib/rouge/lexers/graphql.rb +62 -62
- data/lib/rouge/lexers/groovy.rb +23 -25
- data/lib/rouge/lexers/hack.rb +1 -1
- data/lib/rouge/lexers/haml.rb +25 -29
- data/lib/rouge/lexers/handlebars.rb +18 -18
- data/lib/rouge/lexers/haskell.rb +66 -65
- data/lib/rouge/lexers/hcl.rb +25 -25
- data/lib/rouge/lexers/html.rb +31 -31
- data/lib/rouge/lexers/http.rb +4 -4
- data/lib/rouge/lexers/hylang.rb +14 -14
- data/lib/rouge/lexers/idlang.rb +32 -32
- data/lib/rouge/lexers/igorpro.rb +30 -30
- data/lib/rouge/lexers/ini.rb +12 -12
- data/lib/rouge/lexers/io.rb +7 -7
- data/lib/rouge/lexers/irb.rb +5 -5
- data/lib/rouge/lexers/java.rb +24 -24
- data/lib/rouge/lexers/javascript.rb +51 -51
- data/lib/rouge/lexers/jinja.rb +22 -22
- data/lib/rouge/lexers/json.rb +11 -10
- data/lib/rouge/lexers/json_doc.rb +2 -2
- data/lib/rouge/lexers/jsonnet.rb +18 -18
- data/lib/rouge/lexers/jsp.rb +28 -28
- data/lib/rouge/lexers/jsx.rb +16 -16
- data/lib/rouge/lexers/julia.rb +44 -44
- data/lib/rouge/lexers/kotlin.rb +3 -3
- data/lib/rouge/lexers/lasso.rb +50 -50
- data/lib/rouge/lexers/liquid.rb +53 -53
- data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
- data/lib/rouge/lexers/literate_haskell.rb +5 -5
- data/lib/rouge/lexers/llvm.rb +23 -16
- data/lib/rouge/lexers/lua.rb +3 -3
- data/lib/rouge/lexers/m68k.rb +18 -19
- data/lib/rouge/lexers/magik.rb +126 -0
- data/lib/rouge/lexers/make.rb +22 -28
- data/lib/rouge/lexers/markdown.rb +37 -37
- data/lib/rouge/lexers/mathematica.rb +11 -11
- data/lib/rouge/lexers/matlab.rb +20 -20
- data/lib/rouge/lexers/moonscript.rb +3 -3
- data/lib/rouge/lexers/mosel.rb +17 -17
- data/lib/rouge/lexers/mxml.rb +18 -18
- data/lib/rouge/lexers/nasm.rb +24 -25
- data/lib/rouge/lexers/nginx.rb +14 -14
- data/lib/rouge/lexers/nim.rb +1 -1
- data/lib/rouge/lexers/nix.rb +42 -42
- data/lib/rouge/lexers/objective_c.rb +38 -38
- data/lib/rouge/lexers/ocaml.rb +29 -29
- data/lib/rouge/lexers/pascal.rb +4 -4
- data/lib/rouge/lexers/perl.rb +68 -68
- data/lib/rouge/lexers/php.rb +38 -38
- data/lib/rouge/lexers/plist.rb +14 -14
- data/lib/rouge/lexers/pony.rb +19 -19
- data/lib/rouge/lexers/powershell.rb +25 -25
- data/lib/rouge/lexers/praat.rb +75 -75
- data/lib/rouge/lexers/prolog.rb +26 -20
- data/lib/rouge/lexers/prometheus.rb +30 -30
- data/lib/rouge/lexers/properties.rb +12 -12
- data/lib/rouge/lexers/protobuf.rb +22 -22
- data/lib/rouge/lexers/puppet.rb +31 -31
- data/lib/rouge/lexers/python.rb +52 -52
- data/lib/rouge/lexers/q.rb +12 -12
- data/lib/rouge/lexers/qml.rb +12 -12
- data/lib/rouge/lexers/r.rb +12 -12
- data/lib/rouge/lexers/racket.rb +22 -22
- data/lib/rouge/lexers/ruby.rb +71 -69
- data/lib/rouge/lexers/rust.rb +30 -30
- data/lib/rouge/lexers/sass.rb +8 -8
- data/lib/rouge/lexers/sass/common.rb +40 -40
- data/lib/rouge/lexers/scala.rb +43 -43
- data/lib/rouge/lexers/scheme.rb +18 -18
- data/lib/rouge/lexers/scss.rb +3 -3
- data/lib/rouge/lexers/sed.rb +29 -29
- data/lib/rouge/lexers/shell.rb +61 -52
- data/lib/rouge/lexers/sieve.rb +8 -8
- data/lib/rouge/lexers/slim.rb +24 -24
- data/lib/rouge/lexers/smalltalk.rb +33 -33
- data/lib/rouge/lexers/smarty.rb +12 -12
- data/lib/rouge/lexers/sml.rb +67 -67
- data/lib/rouge/lexers/sqf.rb +1 -1
- data/lib/rouge/lexers/sql.rb +21 -21
- data/lib/rouge/lexers/supercollider.rb +19 -19
- data/lib/rouge/lexers/swift.rb +42 -39
- data/lib/rouge/lexers/tap.rb +20 -20
- data/lib/rouge/lexers/tcl.rb +27 -27
- data/lib/rouge/lexers/terraform.rb +13 -13
- data/lib/rouge/lexers/tex.rb +19 -19
- data/lib/rouge/lexers/toml.rb +18 -18
- data/lib/rouge/lexers/tulip.rb +36 -36
- data/lib/rouge/lexers/turtle.rb +35 -38
- data/lib/rouge/lexers/vala.rb +17 -17
- data/lib/rouge/lexers/vb.rb +27 -27
- data/lib/rouge/lexers/verilog.rb +25 -27
- data/lib/rouge/lexers/vhdl.rb +10 -10
- data/lib/rouge/lexers/viml.rb +14 -14
- data/lib/rouge/lexers/vue.rb +9 -9
- data/lib/rouge/lexers/wollok.rb +25 -25
- data/lib/rouge/lexers/xml.rb +17 -21
- data/lib/rouge/lexers/xojo.rb +15 -15
- data/lib/rouge/lexers/yaml.rb +61 -61
- data/lib/rouge/plugins/redcarpet.rb +1 -1
- data/lib/rouge/tex_theme_renderer.rb +128 -0
- data/lib/rouge/theme.rb +4 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/version.rb +1 -1
- metadata +11 -2
data/lib/rouge/lexers/scheme.rb
CHANGED
@@ -61,33 +61,33 @@ module Rouge
|
|
61
61
|
|
62
62
|
state :root do
|
63
63
|
# comments
|
64
|
-
rule /;.*$/, Comment::Single
|
65
|
-
rule /\s+/m, Text
|
66
|
-
rule /-?\d+\.\d+/, Num::Float
|
67
|
-
rule /-?\d+/, Num::Integer
|
64
|
+
rule %r/;.*$/, Comment::Single
|
65
|
+
rule %r/\s+/m, Text
|
66
|
+
rule %r/-?\d+\.\d+/, Num::Float
|
67
|
+
rule %r/-?\d+/, Num::Integer
|
68
68
|
|
69
69
|
# Racket infinitites
|
70
|
-
rule /[+-]inf[.][f0]/, Num
|
70
|
+
rule %r/[+-]inf[.][f0]/, Num
|
71
71
|
|
72
|
-
rule /#b[01]+/, Num::Bin
|
73
|
-
rule /#o[0-7]+/, Num::Oct
|
74
|
-
rule /#d[0-9]+/, Num::Integer
|
75
|
-
rule /#x[0-9a-f]+/i, Num::Hex
|
76
|
-
rule /#[ei][\d.]+/, Num::Other
|
72
|
+
rule %r/#b[01]+/, Num::Bin
|
73
|
+
rule %r/#o[0-7]+/, Num::Oct
|
74
|
+
rule %r/#d[0-9]+/, Num::Integer
|
75
|
+
rule %r/#x[0-9a-f]+/i, Num::Hex
|
76
|
+
rule %r/#[ei][\d.]+/, Num::Other
|
77
77
|
|
78
|
-
rule /"(\\\\|\\"|[^"])*"/, Str
|
79
|
-
rule /'#{id}/i, Str::Symbol
|
80
|
-
rule /#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
|
78
|
+
rule %r/"(\\\\|\\"|[^"])*"/, Str
|
79
|
+
rule %r/'#{id}/i, Str::Symbol
|
80
|
+
rule %r/#\\([()\/'"._!\$%& ?=+-]{1}|[a-z0-9]+)/i,
|
81
81
|
Str::Char
|
82
|
-
rule /#t|#f/, Name::Constant
|
83
|
-
rule /(?:'|#|`|,@|,|\.)/, Operator
|
82
|
+
rule %r/#t|#f/, Name::Constant
|
83
|
+
rule %r/(?:'|#|`|,@|,|\.)/, Operator
|
84
84
|
|
85
|
-
rule /(['#])(\s*)(\()/m do
|
85
|
+
rule %r/(['#])(\s*)(\()/m do
|
86
86
|
groups Str::Symbol, Text, Punctuation
|
87
87
|
end
|
88
88
|
|
89
|
-
rule /\(|\[/, Punctuation, :command
|
90
|
-
rule /\)|\]/, Punctuation
|
89
|
+
rule %r/\(|\[/, Punctuation, :command
|
90
|
+
rule %r/\)|\]/, Punctuation
|
91
91
|
|
92
92
|
rule id, Name::Variable
|
93
93
|
end
|
data/lib/rouge/lexers/scss.rb
CHANGED
@@ -13,10 +13,10 @@ module Rouge
|
|
13
13
|
mimetypes 'text/x-scss'
|
14
14
|
|
15
15
|
state :root do
|
16
|
-
rule /\s+/, Text
|
16
|
+
rule %r/\s+/, Text
|
17
17
|
rule %r(//.*?$), Comment::Single
|
18
18
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
19
|
-
rule /@import\b/, Keyword, :value
|
19
|
+
rule %r/@import\b/, Keyword, :value
|
20
20
|
|
21
21
|
mixin :content_common
|
22
22
|
|
@@ -27,7 +27,7 @@ module Rouge
|
|
27
27
|
end
|
28
28
|
|
29
29
|
state :end_section do
|
30
|
-
rule /\n/, Text
|
30
|
+
rule %r/\n/, Text
|
31
31
|
rule(/[;{}]/) { token Punctuation; reset_stack }
|
32
32
|
end
|
33
33
|
end
|
data/lib/rouge/lexers/sed.rb
CHANGED
@@ -17,15 +17,15 @@ module Rouge
|
|
17
17
|
|
18
18
|
class Regex < RegexLexer
|
19
19
|
state :root do
|
20
|
-
rule /\\./, Str::Escape
|
21
|
-
rule /\[/, Punctuation, :brackets
|
22
|
-
rule /[$^.*]/, Operator
|
23
|
-
rule /[()]/, Punctuation
|
24
|
-
rule /./, Str::Regex
|
20
|
+
rule %r/\\./, Str::Escape
|
21
|
+
rule %r/\[/, Punctuation, :brackets
|
22
|
+
rule %r/[$^.*]/, Operator
|
23
|
+
rule %r/[()]/, Punctuation
|
24
|
+
rule %r/./, Str::Regex
|
25
25
|
end
|
26
26
|
|
27
27
|
state :brackets do
|
28
|
-
rule /\^/ do
|
28
|
+
rule %r/\^/ do
|
29
29
|
token Punctuation
|
30
30
|
goto :brackets_int
|
31
31
|
end
|
@@ -35,17 +35,17 @@ module Rouge
|
|
35
35
|
|
36
36
|
state :brackets_int do
|
37
37
|
# ranges
|
38
|
-
rule /.-./, Name::Variable
|
39
|
-
rule /\]/, Punctuation, :pop!
|
40
|
-
rule /./, Str::Regex
|
38
|
+
rule %r/.-./, Name::Variable
|
39
|
+
rule %r/\]/, Punctuation, :pop!
|
40
|
+
rule %r/./, Str::Regex
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
class Replacement < RegexLexer
|
45
45
|
state :root do
|
46
|
-
rule /\\./m, Str::Escape
|
47
|
-
rule /&/, Operator
|
48
|
-
rule /[^\\&]+/m, Text
|
46
|
+
rule %r/\\./m, Str::Escape
|
47
|
+
rule %r/&/, Operator
|
48
|
+
rule %r/[^\\&]+/m, Text
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -60,7 +60,7 @@ module Rouge
|
|
60
60
|
start { regex.reset!; replacement.reset! }
|
61
61
|
|
62
62
|
state :whitespace do
|
63
|
-
rule /\s+/m, Text
|
63
|
+
rule %r/\s+/m, Text
|
64
64
|
rule(/#.*?\n/) { token Comment; reset_stack }
|
65
65
|
rule(/\n/) { token Text; reset_stack }
|
66
66
|
rule(/;/) { token Punctuation; reset_stack }
|
@@ -76,7 +76,7 @@ module Rouge
|
|
76
76
|
mixin :whitespace
|
77
77
|
|
78
78
|
# subst and transliteration
|
79
|
-
rule /(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
79
|
+
rule %r/(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
80
80
|
token Keyword, m[1]
|
81
81
|
token Punctuation, m[2]
|
82
82
|
delegate regex, m[3]
|
@@ -88,7 +88,7 @@ module Rouge
|
|
88
88
|
goto :flags
|
89
89
|
end
|
90
90
|
|
91
|
-
rule /(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
91
|
+
rule %r/(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
92
92
|
token Keyword, m[1]
|
93
93
|
token Punctuation, m[2]
|
94
94
|
delegate replacement, m[3]
|
@@ -100,29 +100,29 @@ module Rouge
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# commands that take a text segment as an argument
|
103
|
-
rule /([aic])(\s*)/ do
|
103
|
+
rule %r/([aic])(\s*)/ do
|
104
104
|
groups Keyword, Text; goto :text
|
105
105
|
end
|
106
106
|
|
107
|
-
rule /[pd]/, Keyword
|
107
|
+
rule %r/[pd]/, Keyword
|
108
108
|
|
109
109
|
# commands that take a number argument
|
110
|
-
rule /([qQl])(\s+)(\d+)/i do
|
110
|
+
rule %r/([qQl])(\s+)(\d+)/i do
|
111
111
|
groups Keyword, Text, Num
|
112
112
|
pop!
|
113
113
|
end
|
114
114
|
|
115
115
|
# no-argument commands
|
116
|
-
rule /[={}dDgGhHlnpPqx]/, Keyword, :pop!
|
116
|
+
rule %r/[={}dDgGhHlnpPqx]/, Keyword, :pop!
|
117
117
|
|
118
118
|
# commands that take a filename argument
|
119
|
-
rule /([rRwW])(\s+)(\S+)/ do
|
119
|
+
rule %r/([rRwW])(\s+)(\S+)/ do
|
120
120
|
groups Keyword, Text, Name
|
121
121
|
pop!
|
122
122
|
end
|
123
123
|
|
124
124
|
# commands that take a label argument
|
125
|
-
rule /([:btT])(\s+)(\S+)/ do
|
125
|
+
rule %r/([:btT])(\s+)(\S+)/ do
|
126
126
|
groups Keyword, Text, Name::Label
|
127
127
|
pop!
|
128
128
|
end
|
@@ -133,8 +133,8 @@ module Rouge
|
|
133
133
|
|
134
134
|
### address ranges ###
|
135
135
|
addr_tok = Keyword::Namespace
|
136
|
-
rule /\d+/, addr_tok
|
137
|
-
rule /[$,~+!]/, addr_tok
|
136
|
+
rule %r/\d+/, addr_tok
|
137
|
+
rule %r/[$,~+!]/, addr_tok
|
138
138
|
|
139
139
|
rule %r((/)((?:\\.|.)*?)(/)) do |m|
|
140
140
|
token addr_tok, m[1]; delegate regex, m[2]; token addr_tok, m[3]
|
@@ -151,18 +151,18 @@ module Rouge
|
|
151
151
|
end
|
152
152
|
|
153
153
|
state :text do
|
154
|
-
rule /[^\\\n]+/, Str
|
155
|
-
rule /\\\n/, Str::Escape
|
156
|
-
rule /\\/, Str
|
157
|
-
rule /\n/, Text, :pop!
|
154
|
+
rule %r/[^\\\n]+/, Str
|
155
|
+
rule %r/\\\n/, Str::Escape
|
156
|
+
rule %r/\\/, Str
|
157
|
+
rule %r/\n/, Text, :pop!
|
158
158
|
end
|
159
159
|
|
160
160
|
state :flags do
|
161
|
-
rule /[gp]+/, Keyword, :pop!
|
161
|
+
rule %r/[gp]+/, Keyword, :pop!
|
162
162
|
|
163
163
|
# writing to a file with the subst command.
|
164
164
|
# who'da thunk...?
|
165
|
-
rule /([wW])(\s+)(\S+)/ do
|
165
|
+
rule %r/([wW])(\s+)(\S+)/ do
|
166
166
|
token Keyword; token Text; token Name
|
167
167
|
end
|
168
168
|
|
data/lib/rouge/lexers/shell.rb
CHANGED
@@ -44,25 +44,25 @@ module Rouge
|
|
44
44
|
).join('|')
|
45
45
|
|
46
46
|
state :basic do
|
47
|
-
rule /#.*$/, Comment
|
47
|
+
rule %r/#.*$/, Comment
|
48
48
|
|
49
|
-
rule /\b(#{KEYWORDS})\s*\b/, Keyword
|
50
|
-
rule /\bcase\b/, Keyword, :case
|
49
|
+
rule %r/\b(#{KEYWORDS})\s*\b/, Keyword
|
50
|
+
rule %r/\bcase\b/, Keyword, :case
|
51
51
|
|
52
|
-
rule /\b(#{BUILTINS})\s*\b(?!(\.|-))/, Name::Builtin
|
53
|
-
rule /[.](?=\s)/, Name::Builtin
|
52
|
+
rule %r/\b(#{BUILTINS})\s*\b(?!(\.|-))/, Name::Builtin
|
53
|
+
rule %r/[.](?=\s)/, Name::Builtin
|
54
54
|
|
55
|
-
rule /(\b\w+)(=)/ do |m|
|
55
|
+
rule %r/(\b\w+)(=)/ do |m|
|
56
56
|
groups Name::Variable, Operator
|
57
57
|
end
|
58
58
|
|
59
|
-
rule /[\[\]{}()!=>]/, Operator
|
60
|
-
rule /&&|\|\|/, Operator
|
59
|
+
rule %r/[\[\]{}()!=>]/, Operator
|
60
|
+
rule %r/&&|\|\|/, Operator
|
61
61
|
|
62
62
|
# here-string
|
63
|
-
rule /<<</, Operator
|
63
|
+
rule %r/<<</, Operator
|
64
64
|
|
65
|
-
rule /(<<-?)(\s*)(\'?)(\\?)(\w+)(\3)/ do |m|
|
65
|
+
rule %r/(<<-?)(\s*)(\'?)(\\?)(\w+)(\3)/ do |m|
|
66
66
|
groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc
|
67
67
|
@heredocstr = Regexp.escape(m[5])
|
68
68
|
push :heredoc
|
@@ -70,14 +70,14 @@ module Rouge
|
|
70
70
|
end
|
71
71
|
|
72
72
|
state :heredoc do
|
73
|
-
rule /\n/, Str::Heredoc, :heredoc_nl
|
74
|
-
rule /[^$\n]+/, Str::Heredoc
|
73
|
+
rule %r/\n/, Str::Heredoc, :heredoc_nl
|
74
|
+
rule %r/[^$\n\\]+/, Str::Heredoc
|
75
75
|
mixin :interp
|
76
|
-
rule /[$]/, Str::Heredoc
|
76
|
+
rule %r/[$]/, Str::Heredoc
|
77
77
|
end
|
78
78
|
|
79
79
|
state :heredoc_nl do
|
80
|
-
rule /\s*(\w+)\s*\n/ do |m|
|
80
|
+
rule %r/\s*(\w+)\s*\n/ do |m|
|
81
81
|
if m[1] == @heredocstr
|
82
82
|
token Name::Constant
|
83
83
|
pop! 2
|
@@ -93,92 +93,101 @@ module Rouge
|
|
93
93
|
state :double_quotes do
|
94
94
|
# NB: "abc$" is literally the string abc$.
|
95
95
|
# Here we prevent :interp from interpreting $" as a variable.
|
96
|
-
rule /(?:\$#?)?"/, Str::Double, :pop!
|
96
|
+
rule %r/(?:\$#?)?"/, Str::Double, :pop!
|
97
97
|
mixin :interp
|
98
|
-
rule /[^"`\\$]+/, Str::Double
|
98
|
+
rule %r/[^"`\\$]+/, Str::Double
|
99
99
|
end
|
100
100
|
|
101
101
|
state :ansi_string do
|
102
|
-
rule /\\./, Str::Escape
|
103
|
-
rule /[^\\']+/, Str::Single
|
102
|
+
rule %r/\\./, Str::Escape
|
103
|
+
rule %r/[^\\']+/, Str::Single
|
104
104
|
mixin :single_quotes
|
105
105
|
end
|
106
106
|
|
107
107
|
state :single_quotes do
|
108
|
-
rule /'/, Str::Single, :pop!
|
109
|
-
rule /[^']+/, Str::Single
|
108
|
+
rule %r/'/, Str::Single, :pop!
|
109
|
+
rule %r/[^']+/, Str::Single
|
110
110
|
end
|
111
111
|
|
112
112
|
state :data do
|
113
|
-
rule /\s+/, Text
|
114
|
-
rule /\\./, Str::Escape
|
115
|
-
rule /\$?"/, Str::Double, :double_quotes
|
116
|
-
rule /\$'/, Str::Single, :ansi_string
|
113
|
+
rule %r/\s+/, Text
|
114
|
+
rule %r/\\./, Str::Escape
|
115
|
+
rule %r/\$?"/, Str::Double, :double_quotes
|
116
|
+
rule %r/\$'/, Str::Single, :ansi_string
|
117
117
|
|
118
118
|
# single quotes are much easier than double quotes - we can
|
119
119
|
# literally just scan until the next single quote.
|
120
120
|
# POSIX: Enclosing characters in single-quotes ( '' )
|
121
121
|
# shall preserve the literal value of each character within the
|
122
122
|
# single-quotes. A single-quote cannot occur within single-quotes.
|
123
|
-
rule /'/, Str::Single, :single_quotes
|
123
|
+
rule %r/'/, Str::Single, :single_quotes
|
124
124
|
|
125
|
-
rule /\*/, Keyword
|
125
|
+
rule %r/\*/, Keyword
|
126
126
|
|
127
|
-
rule /;/, Punctuation
|
127
|
+
rule %r/;/, Punctuation
|
128
128
|
|
129
|
-
rule /--?[\w-]+/, Name::Tag
|
130
|
-
rule /[^=\*\s{}()$"'`;\\<]+/, Text
|
131
|
-
rule /\d+(?= |\Z)/, Num
|
132
|
-
rule /</, Text
|
129
|
+
rule %r/--?[\w-]+/, Name::Tag
|
130
|
+
rule %r/[^=\*\s{}()$"'`;\\<]+/, Text
|
131
|
+
rule %r/\d+(?= |\Z)/, Num
|
132
|
+
rule %r/</, Text
|
133
133
|
mixin :interp
|
134
134
|
end
|
135
135
|
|
136
136
|
state :curly do
|
137
|
-
rule /}/, Keyword, :pop!
|
138
|
-
rule /:-/, Keyword
|
139
|
-
rule /[a-zA-Z0-9_]+/, Name::Variable
|
140
|
-
rule /[^}:"`'$]+/, Punctuation
|
137
|
+
rule %r/}/, Keyword, :pop!
|
138
|
+
rule %r/:-/, Keyword
|
139
|
+
rule %r/[a-zA-Z0-9_]+/, Name::Variable
|
140
|
+
rule %r/[^}:"`'$]+/, Punctuation
|
141
141
|
mixin :root
|
142
142
|
end
|
143
143
|
|
144
|
-
state
|
145
|
-
|
144
|
+
# the state inside $(...)
|
145
|
+
state :paren_interp do
|
146
|
+
rule %r/\)/, Str::Interpol, :pop!
|
147
|
+
rule %r/\(/, Operator, :paren_inner
|
148
|
+
mixin :root
|
149
|
+
end
|
150
|
+
|
151
|
+
# used to balance parentheses inside interpolation
|
152
|
+
state :paren_inner do
|
153
|
+
rule %r/\(/, Operator, :push
|
154
|
+
rule %r/\)/, Operator, :pop!
|
146
155
|
mixin :root
|
147
156
|
end
|
148
157
|
|
149
158
|
state :math do
|
150
|
-
rule /\)\)/, Keyword, :pop!
|
159
|
+
rule %r/\)\)/, Keyword, :pop!
|
151
160
|
rule %r([-+*/%^|&!]|\*\*|\|\|), Operator
|
152
|
-
rule /\d+(#\w+)?/, Num
|
161
|
+
rule %r/\d+(#\w+)?/, Num
|
153
162
|
mixin :root
|
154
163
|
end
|
155
164
|
|
156
165
|
state :case do
|
157
|
-
rule /\besac\b/, Keyword, :pop!
|
158
|
-
rule /\|/, Punctuation
|
159
|
-
rule /\)/, Punctuation, :case_stanza
|
166
|
+
rule %r/\besac\b/, Keyword, :pop!
|
167
|
+
rule %r/\|/, Punctuation
|
168
|
+
rule %r/\)/, Punctuation, :case_stanza
|
160
169
|
mixin :root
|
161
170
|
end
|
162
171
|
|
163
172
|
state :case_stanza do
|
164
|
-
rule /;;/, Punctuation, :pop!
|
173
|
+
rule %r/;;/, Punctuation, :pop!
|
165
174
|
mixin :root
|
166
175
|
end
|
167
176
|
|
168
177
|
state :backticks do
|
169
|
-
rule /`/, Str::Backtick, :pop!
|
178
|
+
rule %r/`/, Str::Backtick, :pop!
|
170
179
|
mixin :root
|
171
180
|
end
|
172
181
|
|
173
182
|
state :interp do
|
174
|
-
rule /\\$/, Str::Escape # line continuation
|
175
|
-
rule /\\./, Str::Escape
|
176
|
-
rule /\$\(\(/, Keyword, :math
|
177
|
-
rule /\$\(/,
|
178
|
-
rule /\${#?/, Keyword, :curly
|
179
|
-
rule /`/, Str::Backtick, :backticks
|
180
|
-
rule /\$#?(\w+|.)/, Name::Variable
|
181
|
-
rule /\$[*@]/, Name::Variable
|
183
|
+
rule %r/\\$/, Str::Escape # line continuation
|
184
|
+
rule %r/\\./, Str::Escape
|
185
|
+
rule %r/\$\(\(/, Keyword, :math
|
186
|
+
rule %r/\$\(/, Str::Interpol, :paren_interp
|
187
|
+
rule %r/\${#?/, Keyword, :curly
|
188
|
+
rule %r/`/, Str::Backtick, :backticks
|
189
|
+
rule %r/\$#?(\w+|.)/, Name::Variable
|
190
|
+
rule %r/\$[*@]/, Name::Variable
|
182
191
|
end
|
183
192
|
|
184
193
|
state :root do
|
data/lib/rouge/lexers/sieve.rb
CHANGED
@@ -57,23 +57,23 @@ module Rouge
|
|
57
57
|
end
|
58
58
|
|
59
59
|
state :comments_and_whitespace do
|
60
|
-
rule /\s+/, Text
|
60
|
+
rule %r/\s+/, Text
|
61
61
|
rule %r(#.*?\n), Comment::Single
|
62
62
|
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
|
63
63
|
end
|
64
64
|
|
65
65
|
state :string do
|
66
|
-
rule /\\./, Str::Escape
|
67
|
-
rule /"/, Str::Double, :pop!
|
66
|
+
rule %r/\\./, Str::Escape
|
67
|
+
rule %r/"/, Str::Double, :pop!
|
68
68
|
# Variables Extension (rfc5229)
|
69
|
-
rule /\${(?:[0-9][.0-9]*|[a-zA-Z_][.a-zA-Z0-9_]*)}/, Str::Interpol
|
70
|
-
rule /./, Str::Double
|
69
|
+
rule %r/\${(?:[0-9][.0-9]*|[a-zA-Z_][.a-zA-Z0-9_]*)}/, Str::Interpol
|
70
|
+
rule %r/./, Str::Double
|
71
71
|
end
|
72
72
|
|
73
73
|
state :root do
|
74
74
|
mixin :comments_and_whitespace
|
75
75
|
|
76
|
-
rule /[\[\](),;{}]/, Punctuation
|
76
|
+
rule %r/[\[\](),;{}]/, Punctuation
|
77
77
|
|
78
78
|
rule id do |m|
|
79
79
|
if self.class.controls.include? m[0]
|
@@ -89,8 +89,8 @@ module Rouge
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
rule /"/, Str::Double, :string
|
93
|
-
rule /[0-9]+[KMG]/, Num::Integer
|
92
|
+
rule %r/"/, Str::Double, :string
|
93
|
+
rule %r/[0-9]+[KMG]/, Num::Integer
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|