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/digdag.rb
CHANGED
data/lib/rouge/lexers/docker.rb
CHANGED
@@ -18,32 +18,32 @@ module Rouge
|
|
18
18
|
start { @shell = Shell.new(@options) }
|
19
19
|
|
20
20
|
state :root do
|
21
|
-
rule /\s+/, Text
|
21
|
+
rule %r/\s+/, Text
|
22
22
|
|
23
|
-
rule /^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do |m|
|
23
|
+
rule %r/^(ONBUILD)(\s+)(#{KEYWORDS})(.*)/io do |m|
|
24
24
|
groups Keyword, Text::Whitespace, Keyword, Str
|
25
25
|
end
|
26
26
|
|
27
|
-
rule /^(#{KEYWORDS})\b(.*)/io do |m|
|
27
|
+
rule %r/^(#{KEYWORDS})\b(.*)/io do |m|
|
28
28
|
groups Keyword, Str
|
29
29
|
end
|
30
30
|
|
31
|
-
rule /#.*?$/, Comment
|
31
|
+
rule %r/#.*?$/, Comment
|
32
32
|
|
33
|
-
rule /^(ONBUILD\s+)?RUN(\s+)/i do
|
33
|
+
rule %r/^(ONBUILD\s+)?RUN(\s+)/i do
|
34
34
|
token Keyword
|
35
35
|
push :run
|
36
36
|
@shell.reset!
|
37
37
|
end
|
38
38
|
|
39
|
-
rule /\w+/, Text
|
40
|
-
rule /[^\w]+/, Text
|
41
|
-
rule /./, Text
|
39
|
+
rule %r/\w+/, Text
|
40
|
+
rule %r/[^\w]+/, Text
|
41
|
+
rule %r/./, Text
|
42
42
|
end
|
43
43
|
|
44
44
|
state :run do
|
45
|
-
rule /\n/, Text, :pop!
|
46
|
-
rule /\\./m, Str::Escape
|
45
|
+
rule %r/\n/, Text, :pop!
|
46
|
+
rule %r/\\./m, Str::Escape
|
47
47
|
rule(/(\\.|[^\n\\])+/) { delegate @shell }
|
48
48
|
end
|
49
49
|
end
|
data/lib/rouge/lexers/dot.rb
CHANGED
@@ -16,33 +16,33 @@ module Rouge
|
|
16
16
|
end
|
17
17
|
|
18
18
|
state :comments_and_whitespace do
|
19
|
-
rule /\s+/, Text
|
19
|
+
rule %r/\s+/, Text
|
20
20
|
rule %r(#.*?\n), Comment::Single
|
21
21
|
rule %r(//.*?\n), Comment::Single
|
22
22
|
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
|
23
23
|
end
|
24
24
|
|
25
25
|
state :html do
|
26
|
-
rule /[^<>]+/ do
|
26
|
+
rule %r/[^<>]+/ do
|
27
27
|
delegate @html
|
28
28
|
end
|
29
|
-
rule /<.+?>/m do
|
29
|
+
rule %r/<.+?>/m do
|
30
30
|
delegate @html
|
31
31
|
end
|
32
|
-
rule />/, Punctuation, :pop!
|
32
|
+
rule %r/>/, Punctuation, :pop!
|
33
33
|
end
|
34
34
|
|
35
35
|
state :ID do
|
36
|
-
rule /([a-zA-Z][a-zA-Z_0-9]*)(\s*)(=)/ do |m|
|
36
|
+
rule %r/([a-zA-Z][a-zA-Z_0-9]*)(\s*)(=)/ do |m|
|
37
37
|
token Name, m[1]
|
38
38
|
token Text, m[2]
|
39
39
|
token Punctuation, m[3]
|
40
40
|
end
|
41
|
-
rule /[a-zA-Z][a-zA-Z_0-9]*/, Name::Variable
|
42
|
-
rule /([0-9]+)?\.[0-9]+/, Num::Float
|
43
|
-
rule /[0-9]+/, Num::Integer
|
44
|
-
rule /"(\\"|[^"])*"/, Str::Double
|
45
|
-
rule /</ do
|
41
|
+
rule %r/[a-zA-Z][a-zA-Z_0-9]*/, Name::Variable
|
42
|
+
rule %r/([0-9]+)?\.[0-9]+/, Num::Float
|
43
|
+
rule %r/[0-9]+/, Num::Integer
|
44
|
+
rule %r/"(\\"|[^"])*"/, Str::Double
|
45
|
+
rule %r/</ do
|
46
46
|
token Punctuation
|
47
47
|
@html.reset!
|
48
48
|
push :html
|
@@ -52,16 +52,16 @@ module Rouge
|
|
52
52
|
state :a_list do
|
53
53
|
mixin :comments_and_whitespace
|
54
54
|
mixin :ID
|
55
|
-
rule /[=;,]/, Punctuation
|
56
|
-
rule /\]/, Operator, :pop!
|
55
|
+
rule %r/[=;,]/, Punctuation
|
56
|
+
rule %r/\]/, Operator, :pop!
|
57
57
|
end
|
58
58
|
|
59
59
|
state :root do
|
60
60
|
mixin :comments_and_whitespace
|
61
|
-
rule /\b(strict|graph|digraph|subgraph|node|edge)\b/i, Keyword
|
62
|
-
rule /[{};:=]/, Punctuation
|
63
|
-
rule /-[->]/, Operator
|
64
|
-
rule /\[/, Operator, :a_list
|
61
|
+
rule %r/\b(strict|graph|digraph|subgraph|node|edge)\b/i, Keyword
|
62
|
+
rule %r/[{};:=]/, Punctuation
|
63
|
+
rule %r/-[->]/, Operator
|
64
|
+
rule %r/\[/, Operator, :a_list
|
65
65
|
mixin :ID
|
66
66
|
end
|
67
67
|
end
|
data/lib/rouge/lexers/eiffel.rb
CHANGED
@@ -27,37 +27,37 @@ module Rouge
|
|
27
27
|
SimpleString = /(?:[^"%\b\f\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)+?/
|
28
28
|
|
29
29
|
state :root do
|
30
|
-
rule /"\[/, Str::Other, :aligned_verbatim_string
|
31
|
-
rule /"\{/, Str::Other, :non_aligned_verbatim_string
|
32
|
-
rule /"(?:[^%\b\f\n\r\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)*?"/, Str::Double
|
33
|
-
rule /--.*/, Comment::Single
|
34
|
-
rule /'(?:[^%\b\f\n\r\t\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)'/, Str::Char
|
30
|
+
rule %r/"\[/, Str::Other, :aligned_verbatim_string
|
31
|
+
rule %r/"\{/, Str::Other, :non_aligned_verbatim_string
|
32
|
+
rule %r/"(?:[^%\b\f\n\r\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)*?"/, Str::Double
|
33
|
+
rule %r/--.*/, Comment::Single
|
34
|
+
rule %r/'(?:[^%\b\f\n\r\t\v]|%[A-DFHLNQR-V%'"()<>]|%\/(?:0[xX][\da-fA-F](?:_*[\da-fA-F])*|0[cC][0-7](?:_*[0-7])*|0[bB][01](?:_*[01])*|\d(?:_*\d)*)\/)'/, Str::Char
|
35
35
|
|
36
|
-
rule /(?:#{LanguageKeywords.join('|')})\b/, Keyword
|
37
|
-
rule /(?:#{LanguageVariables.join('|')})\b/, Keyword::Variable
|
38
|
-
rule /(?:#{BooleanConstants.join('|')})\b/, Keyword::Constant
|
36
|
+
rule %r/(?:#{LanguageKeywords.join('|')})\b/, Keyword
|
37
|
+
rule %r/(?:#{LanguageVariables.join('|')})\b/, Keyword::Variable
|
38
|
+
rule %r/(?:#{BooleanConstants.join('|')})\b/, Keyword::Constant
|
39
39
|
|
40
|
-
rule
|
41
|
-
rule /\b0[cC][0-7](?:_*[0-7])*\b/, Num::Oct
|
42
|
-
rule /\b0[bB][01](?:_*[01])*\b/, Num::Bin
|
43
|
-
rule /\d(?:_*\d)*/, Num::Integer
|
44
|
-
rule /(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/, Num::Float
|
40
|
+
rule %r/\b0[xX][\da-fA-F](?:_*[\da-fA-F])*b/, Num::Hex
|
41
|
+
rule %r/\b0[cC][0-7](?:_*[0-7])*\b/, Num::Oct
|
42
|
+
rule %r/\b0[bB][01](?:_*[01])*\b/, Num::Bin
|
43
|
+
rule %r/\d(?:_*\d)*/, Num::Integer
|
44
|
+
rule %r/(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/, Num::Float
|
45
45
|
|
46
|
-
rule /:=|<<|>>|\(\||\|\)|->|\.|[{}\[\];(),:?]/, Punctuation::Indicator
|
47
|
-
rule /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/, Operator
|
46
|
+
rule %r/:=|<<|>>|\(\||\|\)|->|\.|[{}\[\];(),:?]/, Punctuation::Indicator
|
47
|
+
rule %r/\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/, Operator
|
48
48
|
|
49
|
-
rule /[A-Z][\dA-Z_]*/, Name::Class
|
50
|
-
rule /[A-Za-z][\dA-Za-z_]*/, Name
|
51
|
-
rule /\s+/, Text
|
49
|
+
rule %r/[A-Z][\dA-Z_]*/, Name::Class
|
50
|
+
rule %r/[A-Za-z][\dA-Za-z_]*/, Name
|
51
|
+
rule %r/\s+/, Text
|
52
52
|
end
|
53
53
|
|
54
54
|
state :aligned_verbatim_string do
|
55
|
-
rule /]"/, Str::Other, :pop!
|
55
|
+
rule %r/]"/, Str::Other, :pop!
|
56
56
|
rule SimpleString, Str::Other
|
57
57
|
end
|
58
58
|
|
59
59
|
state :non_aligned_verbatim_string do
|
60
|
-
rule /}"/, Str::Other, :pop!
|
60
|
+
rule %r/}"/, Str::Other, :pop!
|
61
61
|
rule SimpleString, Str::Other
|
62
62
|
end
|
63
63
|
end
|
data/lib/rouge/lexers/elixir.rb
CHANGED
@@ -17,27 +17,27 @@ module Rouge
|
|
17
17
|
mimetypes 'text/x-elixir', 'application/x-elixir'
|
18
18
|
|
19
19
|
state :root do
|
20
|
-
rule /\s+/m, Text
|
21
|
-
rule /#.*$/, Comment::Single
|
20
|
+
rule %r/\s+/m, Text
|
21
|
+
rule %r/#.*$/, Comment::Single
|
22
22
|
rule %r{\b(case|cond|end|bc|lc|if|unless|try|loop|receive|fn|defmodule|
|
23
23
|
defp?|defprotocol|defimpl|defrecord|defmacrop?|defdelegate|
|
24
24
|
defexception|defguardp?|defstruct|exit|raise|throw|after|rescue|catch|else)\b(?![?!])|
|
25
25
|
(?<!\.)\b(do|\-\>)\b}x, Keyword
|
26
|
-
rule /\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])/, Keyword::Namespace
|
27
|
-
rule /(?<!\.)\b(and|not|or|when|xor|in)\b/, Operator::Word
|
26
|
+
rule %r/\b(import|require|use|recur|quote|unquote|super|refer)\b(?![?!])/, Keyword::Namespace
|
27
|
+
rule %r/(?<!\.)\b(and|not|or|when|xor|in)\b/, Operator::Word
|
28
28
|
rule %r{%=|\*=|\*\*=|\+=|\-=|\^=|\|\|=|
|
29
|
-
<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[\s
|
30
|
-
(?<=[\s
|
29
|
+
<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?=[\s])\?|
|
30
|
+
(?<=[\s])!+|&(&&?|(?!\d))|\|\||\^|\*|\+|\-|/|
|
31
31
|
\||\+\+|\-\-|\*\*|\/\/|\<\-|\<\>|<<|>>|=|\.|~~~}x, Operator
|
32
32
|
rule %r{(?<!:)(:)([a-zA-Z_]\w*([?!]|=(?![>=]))?|\<\>|===?|>=?|<=?|
|
33
33
|
<=>|&&?|%\(\)|%\[\]|%\{\}|\+\+?|\-\-?|\|\|?|\!|//|[%&`/\|]|
|
34
34
|
\*\*?|=?~|<\-)|([a-zA-Z_]\w*([?!])?)(:)(?!:)}, Str::Symbol
|
35
|
-
rule /:"/, Str::Symbol, :interpoling_symbol
|
36
|
-
rule /\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b/, Name::Constant
|
37
|
-
rule /\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])/, Name::Builtin::Pseudo
|
38
|
-
rule /[a-zA-Z_!]
|
35
|
+
rule %r/:"/, Str::Symbol, :interpoling_symbol
|
36
|
+
rule %r/\b(nil|true|false)\b(?![?!])|\b[A-Z]\w*\b/, Name::Constant
|
37
|
+
rule %r/\b(__(FILE|LINE|MODULE|MAIN|FUNCTION)__)\b(?![?!])/, Name::Builtin::Pseudo
|
38
|
+
rule %r/[a-zA-Z_!]\w*[!\?]?/, Name
|
39
39
|
rule %r{::|[%(){};,/\|:\\\[\]]}, Punctuation
|
40
|
-
rule /@[a-zA-Z_]\w*|&\d/, Name::Variable
|
40
|
+
rule %r/@[a-zA-Z_]\w*|&\d/, Name::Variable
|
41
41
|
rule %r{\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s])
|
42
42
|
(_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, Num
|
43
43
|
|
@@ -46,37 +46,37 @@ module Rouge
|
|
46
46
|
end
|
47
47
|
|
48
48
|
state :strings do
|
49
|
-
rule /(%[A-Ba-z])?"""(?:.|\n)*?"""/, Str::Doc
|
50
|
-
rule /'''(?:.|\n)*?'''/, Str::Doc
|
51
|
-
rule /"/, Str::Doc, :dqs
|
52
|
-
rule /'.*?'/, Str::Single
|
49
|
+
rule %r/(%[A-Ba-z])?"""(?:.|\n)*?"""/, Str::Doc
|
50
|
+
rule %r/'''(?:.|\n)*?'''/, Str::Doc
|
51
|
+
rule %r/"/, Str::Doc, :dqs
|
52
|
+
rule %r/'.*?'/, Str::Single
|
53
53
|
rule %r{(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b[^x0MC])|(\\[MC]-)+\w|[^\s\\])}, Str::Other
|
54
54
|
|
55
55
|
end
|
56
56
|
|
57
57
|
state :dqs do
|
58
|
-
rule /"/, Str::Double, :pop!
|
58
|
+
rule %r/"/, Str::Double, :pop!
|
59
59
|
mixin :enddoublestr
|
60
60
|
end
|
61
61
|
|
62
62
|
state :interpoling do
|
63
|
-
rule /#\{/, Str::Interpol, :interpoling_string
|
63
|
+
rule %r/#\{/, Str::Interpol, :interpoling_string
|
64
64
|
end
|
65
65
|
|
66
66
|
state :interpoling_string do
|
67
|
-
rule /\}/, Str::Interpol, :pop!
|
67
|
+
rule %r/\}/, Str::Interpol, :pop!
|
68
68
|
mixin :root
|
69
69
|
end
|
70
70
|
|
71
71
|
state :interpoling_symbol do
|
72
|
-
rule /"/, Str::Symbol, :pop!
|
72
|
+
rule %r/"/, Str::Symbol, :pop!
|
73
73
|
mixin :interpoling
|
74
|
-
rule /[^#"]+/, Str::Symbol
|
74
|
+
rule %r/[^#"]+/, Str::Symbol
|
75
75
|
end
|
76
76
|
|
77
77
|
state :enddoublestr do
|
78
78
|
mixin :interpoling
|
79
|
-
rule /[^#"]+/, Str::Double
|
79
|
+
rule %r/[^#"]+/, Str::Double
|
80
80
|
end
|
81
81
|
|
82
82
|
state :sigil_strings do
|
@@ -86,7 +86,7 @@ module Rouge
|
|
86
86
|
delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
|
87
87
|
# Match a-z for custom sigils too
|
88
88
|
sigil_opens = Regexp.union(delimiter_map.keys + %w(| / ' "))
|
89
|
-
rule /~([A-Za-z])?(#{sigil_opens})/ do |m|
|
89
|
+
rule %r/~([A-Za-z])?(#{sigil_opens})/ do |m|
|
90
90
|
open = Regexp.escape(m[2])
|
91
91
|
close = Regexp.escape(delimiter_map[m[2]] || m[2])
|
92
92
|
interp = /[SRCW]/ === m[1]
|
@@ -108,26 +108,27 @@ module Rouge
|
|
108
108
|
token toktype
|
109
109
|
|
110
110
|
push do
|
111
|
-
rule /#{close}/, toktype, :pop!
|
111
|
+
rule %r/#{close}/, toktype, :pop!
|
112
112
|
|
113
113
|
if interp
|
114
114
|
mixin :interpoling
|
115
|
-
rule /#/, toktype
|
115
|
+
rule %r/#/, toktype
|
116
116
|
else
|
117
|
-
rule /[\\#]/, toktype
|
117
|
+
rule %r/[\\#]/, toktype
|
118
118
|
end
|
119
119
|
|
120
|
-
|
120
|
+
uniq_chars = "#{open}#{close}".squeeze
|
121
|
+
rule %r/[^##{uniq_chars}\\]+/m, toktype
|
121
122
|
end
|
122
123
|
end
|
123
124
|
end
|
124
125
|
|
125
126
|
state :regex_flags do
|
126
|
-
rule /[fgimrsux]*/, Str::Regex, :pop!
|
127
|
+
rule %r/[fgimrsux]*/, Str::Regex, :pop!
|
127
128
|
end
|
128
129
|
|
129
130
|
state :list_flags do
|
130
|
-
rule /[csa]?/, Str::Other, :pop!
|
131
|
+
rule %r/[csa]?/, Str::Other, :pop!
|
131
132
|
end
|
132
133
|
end
|
133
134
|
end
|
data/lib/rouge/lexers/elm.rb
CHANGED
@@ -23,66 +23,66 @@ module Rouge
|
|
23
23
|
|
24
24
|
state :root do
|
25
25
|
# Whitespaces
|
26
|
-
rule /\s+/m, Text
|
26
|
+
rule %r/\s+/m, Text
|
27
27
|
# Single line comments
|
28
|
-
rule /--.*/, Comment::Single
|
28
|
+
rule %r/--.*/, Comment::Single
|
29
29
|
# Multiline comments
|
30
|
-
rule /{-/, Comment::Multiline, :multiline_comment
|
30
|
+
rule %r/{-/, Comment::Multiline, :multiline_comment
|
31
31
|
|
32
32
|
# Keywords
|
33
|
-
rule /\b(#{keywords.join('|')})\b/, Keyword
|
33
|
+
rule %r/\b(#{keywords.join('|')})\b/, Keyword
|
34
34
|
|
35
35
|
# Variable or a function
|
36
|
-
rule /[a-z]
|
36
|
+
rule %r/[a-z]\w*/, Name
|
37
37
|
# Underscore is a name for a variable, when it won't be used later
|
38
|
-
rule /_/, Name
|
38
|
+
rule %r/_/, Name
|
39
39
|
# Type
|
40
|
-
rule /[A-Z]
|
40
|
+
rule %r/[A-Z]\w*/, Keyword::Type
|
41
41
|
|
42
42
|
# Two symbol operators: -> :: // .. && || ++ |> <| << >> == /= <= >=
|
43
|
-
rule /(->|::|\/\/|\.\.|&&|\|\||\+\+|\|>|<\||>>|<<|==|\/=|<=|>=)/, Operator
|
43
|
+
rule %r/(->|::|\/\/|\.\.|&&|\|\||\+\+|\|>|<\||>>|<<|==|\/=|<=|>=)/, Operator
|
44
44
|
# One symbol operators: + - / * % = < > ^ | !
|
45
|
-
rule /[+-\/*%=<>^\|!]/, Operator
|
45
|
+
rule %r/[+-\/*%=<>^\|!]/, Operator
|
46
46
|
# Lambda operator
|
47
|
-
rule /\\/, Operator
|
47
|
+
rule %r/\\/, Operator
|
48
48
|
# Not standard Elm operators, but these symbols can be used for custom inflix operators. We need to highlight them as operators as well.
|
49
|
-
rule /[@\#$&~?]/, Operator
|
49
|
+
rule %r/[@\#$&~?]/, Operator
|
50
50
|
|
51
51
|
# Single, double quotes, and triple double quotes
|
52
|
-
rule /"""/, Str, :multiline_string
|
53
|
-
rule /'(\\.|.)'/, Str::Char
|
54
|
-
rule /"/, Str, :double_quote
|
52
|
+
rule %r/"""/, Str, :multiline_string
|
53
|
+
rule %r/'(\\.|.)'/, Str::Char
|
54
|
+
rule %r/"/, Str, :double_quote
|
55
55
|
|
56
56
|
# Numbers
|
57
|
-
rule /0x[\da-f]+/i, Num::Hex
|
58
|
-
rule /\d+e[+-]?\d+/i, Num::Float
|
59
|
-
rule /\d+\.\d+(e[+-]?\d+)?/i, Num::Float
|
60
|
-
rule /\d+/, Num::Integer
|
57
|
+
rule %r/0x[\da-f]+/i, Num::Hex
|
58
|
+
rule %r/\d+e[+-]?\d+/i, Num::Float
|
59
|
+
rule %r/\d+\.\d+(e[+-]?\d+)?/i, Num::Float
|
60
|
+
rule %r/\d+/, Num::Integer
|
61
61
|
|
62
62
|
# Punctuation: [ ] ( ) , ; ` { } :
|
63
|
-
rule /[\[\](),;`{}:]/, Punctuation
|
63
|
+
rule %r/[\[\](),;`{}:]/, Punctuation
|
64
64
|
end
|
65
65
|
|
66
66
|
# Multiline and nested commenting
|
67
67
|
state :multiline_comment do
|
68
|
-
rule /-}/, Comment::Multiline, :pop!
|
69
|
-
rule /{-/, Comment::Multiline, :multiline_comment
|
70
|
-
rule /[^-{}]+/, Comment::Multiline
|
71
|
-
rule /[-{}]/, Comment::Multiline
|
68
|
+
rule %r/-}/, Comment::Multiline, :pop!
|
69
|
+
rule %r/{-/, Comment::Multiline, :multiline_comment
|
70
|
+
rule %r/[^-{}]+/, Comment::Multiline
|
71
|
+
rule %r/[-{}]/, Comment::Multiline
|
72
72
|
end
|
73
73
|
|
74
74
|
# Double quotes
|
75
75
|
state :double_quote do
|
76
|
-
rule /[^\\"]+/, Str::Double
|
77
|
-
rule /\\"/, Str::Escape
|
78
|
-
rule /"/, Str::Double, :pop!
|
76
|
+
rule %r/[^\\"]+/, Str::Double
|
77
|
+
rule %r/\\"/, Str::Escape
|
78
|
+
rule %r/"/, Str::Double, :pop!
|
79
79
|
end
|
80
80
|
|
81
81
|
# Multiple line string with tripple double quotes, e.g. """ multi """
|
82
82
|
state :multiline_string do
|
83
|
-
rule /\s*"""/, Str, :pop!
|
84
|
-
rule /.*/, Str
|
85
|
-
rule /\s*/, Str
|
83
|
+
rule %r/\s*"""/, Str, :pop!
|
84
|
+
rule %r/.*/, Str
|
85
|
+
rule %r/\s*/, Str
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
data/lib/rouge/lexers/erb.rb
CHANGED
@@ -27,24 +27,24 @@ module Rouge
|
|
27
27
|
close = /%%>|-%>|%>/
|
28
28
|
|
29
29
|
state :root do
|
30
|
-
rule /<%#/, Comment, :comment
|
30
|
+
rule %r/<%#/, Comment, :comment
|
31
31
|
|
32
32
|
rule open, Comment::Preproc, :ruby
|
33
33
|
|
34
|
-
rule /.+?(?=#{open})|.+/m do
|
34
|
+
rule %r/.+?(?=#{open})|.+/m do
|
35
35
|
delegate parent
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
state :comment do
|
40
40
|
rule close, Comment, :pop!
|
41
|
-
rule /.+?(?=#{close})|.+/m, Comment
|
41
|
+
rule %r/.+?(?=#{close})|.+/m, Comment
|
42
42
|
end
|
43
43
|
|
44
44
|
state :ruby do
|
45
45
|
rule close, Comment::Preproc, :pop!
|
46
46
|
|
47
|
-
rule /.+?(?=#{close})|.+/m do
|
47
|
+
rule %r/.+?(?=#{close})|.+/m do
|
48
48
|
delegate @ruby_lexer
|
49
49
|
end
|
50
50
|
end
|
data/lib/rouge/lexers/factor.rb
CHANGED
@@ -167,35 +167,35 @@ module Rouge
|
|
167
167
|
end
|
168
168
|
|
169
169
|
state :root do
|
170
|
-
rule /\s+/m, Text
|
170
|
+
rule %r/\s+/m, Text
|
171
171
|
|
172
|
-
rule /(:|::|MACRO:|MEMO:|GENERIC:|HELP:)(\s+)(\S+)/m do
|
172
|
+
rule %r/(:|::|MACRO:|MEMO:|GENERIC:|HELP:)(\s+)(\S+)/m do
|
173
173
|
groups Keyword, Text, Name::Function
|
174
174
|
end
|
175
175
|
|
176
|
-
rule /(M:|HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)/m do
|
176
|
+
rule %r/(M:|HOOK:|GENERIC#)(\s+)(\S+)(\s+)(\S+)/m do
|
177
177
|
groups Keyword, Text, Name::Class, Text, Name::Function
|
178
178
|
end
|
179
179
|
|
180
|
-
rule /\((?=\s)/, Name::Function, :stack_effect
|
181
|
-
rule /;(?=\s)/, Keyword
|
180
|
+
rule %r/\((?=\s)/, Name::Function, :stack_effect
|
181
|
+
rule %r/;(?=\s)/, Keyword
|
182
182
|
|
183
|
-
rule /(USING:)((?:\s|\\\s)+)/m do
|
183
|
+
rule %r/(USING:)((?:\s|\\\s)+)/m do
|
184
184
|
groups Keyword::Namespace, Text
|
185
185
|
push :import
|
186
186
|
end
|
187
187
|
|
188
|
-
rule /(IN:|USE:|UNUSE:|QUALIFIED:|QUALIFIED-WITH:)(\s+)(\S+)/m do
|
188
|
+
rule %r/(IN:|USE:|UNUSE:|QUALIFIED:|QUALIFIED-WITH:)(\s+)(\S+)/m do
|
189
189
|
groups Keyword::Namespace, Text, Name::Namespace
|
190
190
|
end
|
191
191
|
|
192
|
-
rule /(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)/m do
|
192
|
+
rule %r/(FROM:|EXCLUDE:)(\s+)(\S+)(\s+)(=>)/m do
|
193
193
|
groups Keyword::Namespace, Text, Name::Namespace, Text, Punctuation
|
194
194
|
end
|
195
195
|
|
196
|
-
rule /(?:ALIAS|DEFER|FORGET|POSTPONE):/, Keyword::Namespace
|
196
|
+
rule %r/(?:ALIAS|DEFER|FORGET|POSTPONE):/, Keyword::Namespace
|
197
197
|
|
198
|
-
rule /(TUPLE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
|
198
|
+
rule %r/(TUPLE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
|
199
199
|
groups(
|
200
200
|
Keyword, Text,
|
201
201
|
Name::Class, Text,
|
@@ -205,16 +205,16 @@ module Rouge
|
|
205
205
|
push :slots
|
206
206
|
end
|
207
207
|
|
208
|
-
rule /(TUPLE:)(\s+)(\S+)/m do
|
208
|
+
rule %r/(TUPLE:)(\s+)(\S+)/m do
|
209
209
|
groups Keyword, Text, Name::Class
|
210
210
|
push :slots
|
211
211
|
end
|
212
212
|
|
213
|
-
rule /(UNION:|INTERSECTION:)(\s+)(\S+)/m do
|
213
|
+
rule %r/(UNION:|INTERSECTION:)(\s+)(\S+)/m do
|
214
214
|
groups Keyword, Text, Name::Class
|
215
215
|
end
|
216
216
|
|
217
|
-
rule /(PREDICATE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
|
217
|
+
rule %r/(PREDICATE:)(\s+)(\S+)(\s+)(<)(\s+)(\S+)/m do
|
218
218
|
groups(
|
219
219
|
Keyword, Text,
|
220
220
|
Name::Class, Text,
|
@@ -223,7 +223,7 @@ module Rouge
|
|
223
223
|
)
|
224
224
|
end
|
225
225
|
|
226
|
-
rule /(C:)(\s+)(\S+)(\s+)(\S+)/m do
|
226
|
+
rule %r/(C:)(\s+)(\S+)(\s+)(\S+)/m do
|
227
227
|
groups(
|
228
228
|
Keyword, Text,
|
229
229
|
Name::Function, Text,
|
@@ -236,38 +236,38 @@ module Rouge
|
|
236
236
|
|ALIEN|TYPEDEF|FUNCTION|STRUCT):
|
237
237
|
)x, Keyword
|
238
238
|
|
239
|
-
rule /(?:<PRIVATE|PRIVATE>)/, Keyword::Namespace
|
239
|
+
rule %r/(?:<PRIVATE|PRIVATE>)/, Keyword::Namespace
|
240
240
|
|
241
|
-
rule /(MAIN:)(\s+)(\S+)/ do
|
241
|
+
rule %r/(MAIN:)(\s+)(\S+)/ do
|
242
242
|
groups Keyword::Namespace, Text, Name::Function
|
243
243
|
end
|
244
244
|
|
245
245
|
# strings
|
246
|
-
rule /"""\s+.*?\s+"""/, Str
|
247
|
-
rule /"(\\.|[^\\])*?"/, Str
|
248
|
-
rule /(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
|
246
|
+
rule %r/"""\s+.*?\s+"""/, Str
|
247
|
+
rule %r/"(\\.|[^\\])*?"/, Str
|
248
|
+
rule %r/(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
|
249
249
|
|
250
250
|
# comments
|
251
|
-
rule /!\s+.*$/, Comment
|
252
|
-
rule /#!\s+.*$/, Comment
|
251
|
+
rule %r/!\s+.*$/, Comment
|
252
|
+
rule %r/#!\s+.*$/, Comment
|
253
253
|
|
254
254
|
# booleans
|
255
|
-
rule /[tf](?=\s)/, Name::Constant
|
255
|
+
rule %r/[tf](?=\s)/, Name::Constant
|
256
256
|
|
257
257
|
# numbers
|
258
|
-
rule /-?\d+\.\d+(?=\s)/, Num::Float
|
259
|
-
rule /-?\d+(?=\s)/, Num::Integer
|
258
|
+
rule %r/-?\d+\.\d+(?=\s)/, Num::Float
|
259
|
+
rule %r/-?\d+(?=\s)/, Num::Integer
|
260
260
|
|
261
|
-
rule /HEX:\s+[a-fA-F\d]+(?=\s)/m, Num::Hex
|
262
|
-
rule /BIN:\s+[01]+(?=\s)/, Num::Bin
|
263
|
-
rule /OCT:\s+[0-7]+(?=\s)/, Num::Oct
|
261
|
+
rule %r/HEX:\s+[a-fA-F\d]+(?=\s)/m, Num::Hex
|
262
|
+
rule %r/BIN:\s+[01]+(?=\s)/, Num::Bin
|
263
|
+
rule %r/OCT:\s+[0-7]+(?=\s)/, Num::Oct
|
264
264
|
|
265
265
|
rule %r([-+/*=<>^](?=\s)), Operator
|
266
266
|
|
267
|
-
rule /(?:deprecated|final|foldable|flushable|inline|recursive)(?=\s)/,
|
267
|
+
rule %r/(?:deprecated|final|foldable|flushable|inline|recursive)(?=\s)/,
|
268
268
|
Keyword
|
269
269
|
|
270
|
-
rule /\S+/ do |m|
|
270
|
+
rule %r/\S+/ do |m|
|
271
271
|
name = m[0]
|
272
272
|
|
273
273
|
if self.class.builtins.values.any? { |b| b.include? name }
|
@@ -279,24 +279,24 @@ module Rouge
|
|
279
279
|
end
|
280
280
|
|
281
281
|
state :stack_effect do
|
282
|
-
rule /\s+/, Text
|
283
|
-
rule /\(/, Name::Function, :stack_effect
|
284
|
-
rule /\)/, Name::Function, :pop!
|
282
|
+
rule %r/\s+/, Text
|
283
|
+
rule %r/\(/, Name::Function, :stack_effect
|
284
|
+
rule %r/\)/, Name::Function, :pop!
|
285
285
|
|
286
|
-
rule /--/, Name::Function
|
287
|
-
rule /\S+/, Name::Variable
|
286
|
+
rule %r/--/, Name::Function
|
287
|
+
rule %r/\S+/, Name::Variable
|
288
288
|
end
|
289
289
|
|
290
290
|
state :slots do
|
291
|
-
rule /\s+/, Text
|
292
|
-
rule /;(?=\s)/, Keyword, :pop!
|
293
|
-
rule /\S+/, Name::Variable
|
291
|
+
rule %r/\s+/, Text
|
292
|
+
rule %r/;(?=\s)/, Keyword, :pop!
|
293
|
+
rule %r/\S+/, Name::Variable
|
294
294
|
end
|
295
295
|
|
296
296
|
state :import do
|
297
|
-
rule /;(?=\s)/, Keyword, :pop!
|
298
|
-
rule /\s+/, Text
|
299
|
-
rule /\S+/, Name::Namespace
|
297
|
+
rule %r/;(?=\s)/, Keyword, :pop!
|
298
|
+
rule %r/\s+/, Text
|
299
|
+
rule %r/\S+/, Name::Namespace
|
300
300
|
end
|
301
301
|
end
|
302
302
|
end
|