rouge 3.1.0 → 3.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +17 -3
- data/bin/rougify +1 -0
- data/lib/rouge.rb +67 -42
- data/lib/rouge/cli.rb +87 -18
- data/lib/rouge/demos/ada +26 -0
- data/lib/rouge/demos/apex +9 -0
- data/lib/rouge/demos/armasm +12 -0
- data/lib/rouge/demos/batchfile +3 -0
- data/lib/rouge/demos/bbcbasic +6 -0
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/clean +6 -0
- data/lib/rouge/demos/cmhg +8 -0
- data/lib/rouge/demos/crystal +45 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/cuda +11 -0
- data/lib/rouge/demos/cypher +5 -0
- data/lib/rouge/demos/cython +6 -0
- data/lib/rouge/demos/datastudio +21 -0
- data/lib/rouge/demos/ecl +18 -0
- data/lib/rouge/demos/eex +1 -0
- data/lib/rouge/demos/epp +4 -0
- data/lib/rouge/demos/escape +3 -0
- data/lib/rouge/demos/freefem +16 -0
- data/lib/rouge/demos/gdscript +18 -0
- data/lib/rouge/demos/ghc-cmm +23 -0
- data/lib/rouge/demos/ghc-core +26 -0
- data/lib/rouge/demos/haxe +5 -0
- data/lib/rouge/demos/hcl +7 -0
- data/lib/rouge/demos/hocon +8 -0
- data/lib/rouge/demos/hql +5 -0
- data/lib/rouge/demos/isbl +4 -0
- data/lib/rouge/demos/jsl +3 -0
- data/lib/rouge/demos/jsp +29 -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/m68k +16 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/demos/mason +22 -0
- data/lib/rouge/demos/mathematica +8 -0
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/msgtrans +4 -0
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/nesasm +11 -0
- data/lib/rouge/demos/objective_cpp +17 -0
- data/lib/rouge/demos/openedge +4 -0
- data/lib/rouge/demos/opentype_feature_file +6 -0
- data/lib/rouge/demos/plist +1 -132
- data/lib/rouge/demos/powershell +12 -48
- data/lib/rouge/demos/q +6 -0
- data/lib/rouge/demos/reasonml +12 -0
- data/lib/rouge/demos/rego +8 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/sas +13 -0
- data/lib/rouge/demos/slice +10 -0
- data/lib/rouge/demos/solidity +13 -0
- data/lib/rouge/demos/sparql +6 -0
- data/lib/rouge/demos/sqf +14 -0
- data/lib/rouge/demos/supercollider +11 -0
- data/lib/rouge/demos/terraform +16 -0
- data/lib/rouge/demos/ttcn3 +6 -0
- data/lib/rouge/demos/vcl +12 -0
- data/lib/rouge/demos/xojo +14 -0
- data/lib/rouge/demos/xpath +2 -0
- data/lib/rouge/demos/xquery +22 -0
- data/lib/rouge/demos/yang +17 -0
- data/lib/rouge/formatter.rb +39 -2
- data/lib/rouge/formatters/html.rb +21 -2
- data/lib/rouge/formatters/html_inline.rb +1 -0
- data/lib/rouge/formatters/html_legacy.rb +1 -0
- data/lib/rouge/formatters/html_line_table.rb +53 -0
- data/lib/rouge/formatters/html_linewise.rb +7 -11
- data/lib/rouge/formatters/html_pygments.rb +2 -0
- data/lib/rouge/formatters/html_table.rb +21 -31
- data/lib/rouge/formatters/null.rb +1 -0
- data/lib/rouge/formatters/terminal256.rb +23 -5
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/formatters/tex.rb +92 -0
- data/lib/rouge/guesser.rb +2 -0
- data/lib/rouge/guessers/disambiguation.rb +35 -0
- data/lib/rouge/guessers/filename.rb +2 -0
- data/lib/rouge/guessers/glob_mapping.rb +3 -1
- data/lib/rouge/guessers/mimetype.rb +2 -0
- data/lib/rouge/guessers/modeline.rb +3 -1
- data/lib/rouge/guessers/source.rb +3 -1
- data/lib/rouge/guessers/util.rb +2 -0
- data/lib/rouge/lexer.rb +71 -15
- data/lib/rouge/lexers/abap.rb +13 -11
- data/lib/rouge/lexers/actionscript.rb +35 -34
- data/lib/rouge/lexers/ada.rb +162 -0
- data/lib/rouge/lexers/apache.rb +13 -15
- data/lib/rouge/lexers/apache/keywords.rb +15 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/apiblueprint.rb +2 -0
- data/lib/rouge/lexers/apple_script.rb +17 -14
- data/lib/rouge/lexers/armasm.rb +145 -0
- data/lib/rouge/lexers/awk.rb +26 -25
- data/lib/rouge/lexers/batchfile.rb +164 -0
- data/lib/rouge/lexers/bbcbasic.rb +112 -0
- data/lib/rouge/lexers/biml.rb +6 -4
- data/lib/rouge/lexers/bpf.rb +118 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +13 -12
- data/lib/rouge/lexers/c.rb +35 -57
- data/lib/rouge/lexers/ceylon.rb +7 -34
- data/lib/rouge/lexers/cfscript.rb +27 -26
- data/lib/rouge/lexers/clean.rb +156 -0
- data/lib/rouge/lexers/clojure.rb +15 -14
- data/lib/rouge/lexers/cmake.rb +16 -14
- data/lib/rouge/lexers/cmhg.rb +34 -0
- data/lib/rouge/lexers/coffeescript.rb +90 -49
- data/lib/rouge/lexers/common_lisp.rb +39 -38
- data/lib/rouge/lexers/conf.rb +7 -6
- data/lib/rouge/lexers/console.rb +92 -38
- data/lib/rouge/lexers/coq.rb +27 -23
- data/lib/rouge/lexers/cpp.rb +24 -13
- data/lib/rouge/lexers/crystal.rb +430 -0
- data/lib/rouge/lexers/csharp.rb +29 -29
- data/lib/rouge/lexers/css.rb +24 -23
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/cuda.rb +35 -0
- data/lib/rouge/lexers/cypher.rb +108 -0
- data/lib/rouge/lexers/cython.rb +151 -0
- data/lib/rouge/lexers/d.rb +64 -63
- data/lib/rouge/lexers/dart.rb +34 -33
- data/lib/rouge/lexers/datastudio.rb +138 -0
- data/lib/rouge/lexers/diff.rb +10 -4
- data/lib/rouge/lexers/digdag.rb +3 -1
- data/lib/rouge/lexers/docker.rb +12 -11
- data/lib/rouge/lexers/dot.rb +19 -18
- data/lib/rouge/lexers/ecl.rb +175 -0
- data/lib/rouge/lexers/eex.rb +52 -0
- data/lib/rouge/lexers/eiffel.rb +21 -20
- data/lib/rouge/lexers/elixir.rb +52 -36
- data/lib/rouge/lexers/elm.rb +30 -29
- data/lib/rouge/lexers/epp.rb +51 -0
- data/lib/rouge/lexers/erb.rb +5 -4
- data/lib/rouge/lexers/erlang.rb +1 -0
- data/lib/rouge/lexers/escape.rb +58 -0
- data/lib/rouge/lexers/factor.rb +41 -40
- data/lib/rouge/lexers/fortran.rb +36 -34
- data/lib/rouge/lexers/freefem.rb +240 -0
- data/lib/rouge/lexers/fsharp.rb +33 -31
- data/lib/rouge/lexers/gdscript.rb +171 -0
- data/lib/rouge/lexers/ghc_cmm.rb +340 -0
- data/lib/rouge/lexers/ghc_core.rb +151 -0
- data/lib/rouge/lexers/gherkin.rb +17 -14
- data/lib/rouge/lexers/gherkin/keywords.rb +2 -0
- data/lib/rouge/lexers/glsl.rb +2 -5
- data/lib/rouge/lexers/go.rb +3 -2
- data/lib/rouge/lexers/gradle.rb +1 -0
- data/lib/rouge/lexers/graphql.rb +78 -60
- data/lib/rouge/lexers/groovy.rb +24 -25
- data/lib/rouge/lexers/hack.rb +2 -1
- data/lib/rouge/lexers/haml.rb +26 -29
- data/lib/rouge/lexers/handlebars.rb +32 -20
- data/lib/rouge/lexers/haskell.rb +78 -61
- data/lib/rouge/lexers/haxe.rb +246 -0
- data/lib/rouge/lexers/hcl.rb +163 -0
- data/lib/rouge/lexers/hocon.rb +86 -0
- data/lib/rouge/lexers/hql.rb +139 -0
- data/lib/rouge/lexers/html.rb +36 -33
- data/lib/rouge/lexers/http.rb +10 -9
- data/lib/rouge/lexers/hylang.rb +15 -14
- data/lib/rouge/lexers/idlang.rb +34 -32
- data/lib/rouge/lexers/igorpro.rb +481 -225
- data/lib/rouge/lexers/ini.rb +13 -12
- data/lib/rouge/lexers/io.rb +10 -9
- data/lib/rouge/lexers/irb.rb +6 -5
- data/lib/rouge/lexers/isbl.rb +97 -0
- data/lib/rouge/lexers/isbl/builtins.rb +17 -0
- data/lib/rouge/lexers/java.rb +30 -26
- data/lib/rouge/lexers/javascript.rb +59 -61
- data/lib/rouge/lexers/jinja.rb +39 -22
- data/lib/rouge/lexers/jsl.rb +55 -0
- data/lib/rouge/lexers/json.rb +54 -11
- data/lib/rouge/lexers/json_doc.rb +8 -5
- data/lib/rouge/lexers/jsonnet.rb +19 -18
- data/lib/rouge/lexers/jsp.rb +120 -0
- data/lib/rouge/lexers/jsx.rb +18 -16
- data/lib/rouge/lexers/julia.rb +192 -74
- data/lib/rouge/lexers/kotlin.rb +79 -27
- data/lib/rouge/lexers/lasso.rb +54 -58
- data/lib/rouge/lexers/lasso/keywords.rb +14 -0
- data/lib/rouge/lexers/liquid.rb +116 -118
- data/lib/rouge/lexers/literate_coffeescript.rb +3 -2
- data/lib/rouge/lexers/literate_haskell.rb +6 -5
- data/lib/rouge/lexers/llvm.rb +66 -49
- data/lib/rouge/lexers/lua.rb +43 -4
- data/lib/rouge/lexers/lua/builtins.rb +2 -0
- data/lib/rouge/lexers/lustre.rb +79 -0
- data/lib/rouge/lexers/lutin.rb +33 -0
- data/lib/rouge/lexers/m68k.rb +143 -0
- data/lib/rouge/lexers/magik.rb +127 -0
- data/lib/rouge/lexers/make.rb +57 -34
- data/lib/rouge/lexers/markdown.rb +67 -39
- data/lib/rouge/lexers/mason.rb +110 -0
- data/lib/rouge/lexers/mathematica.rb +96 -0
- data/lib/rouge/lexers/mathematica/builtins.rb +13 -0
- data/lib/rouge/lexers/matlab.rb +26 -17
- data/lib/rouge/lexers/matlab/builtins.rb +4 -4
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/moonscript.rb +4 -3
- data/lib/rouge/lexers/mosel.rb +64 -63
- data/lib/rouge/lexers/msgtrans.rb +26 -0
- data/lib/rouge/lexers/mxml.rb +19 -18
- data/lib/rouge/lexers/nasm.rb +43 -169
- data/lib/rouge/lexers/nesasm.rb +78 -0
- data/lib/rouge/lexers/nginx.rb +15 -14
- data/lib/rouge/lexers/nim.rb +4 -2
- data/lib/rouge/lexers/nix.rb +48 -42
- data/lib/rouge/lexers/objective_c.rb +5 -178
- data/lib/rouge/lexers/objective_c/common.rb +184 -0
- data/lib/rouge/lexers/objective_cpp.rb +31 -0
- data/lib/rouge/lexers/ocaml.rb +29 -64
- data/lib/rouge/lexers/ocaml/common.rb +53 -0
- data/lib/rouge/lexers/openedge.rb +429 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
- data/lib/rouge/lexers/pascal.rb +6 -5
- data/lib/rouge/lexers/perl.rb +103 -68
- data/lib/rouge/lexers/php.rb +91 -53
- data/lib/rouge/lexers/php/builtins.rb +183 -174
- data/lib/rouge/lexers/plain_text.rb +2 -1
- data/lib/rouge/lexers/plist.rb +16 -14
- data/lib/rouge/lexers/pony.rb +21 -20
- data/lib/rouge/lexers/powershell.rb +190 -638
- data/lib/rouge/lexers/praat.rb +76 -75
- data/lib/rouge/lexers/prolog.rb +27 -19
- data/lib/rouge/lexers/prometheus.rb +32 -30
- data/lib/rouge/lexers/properties.rb +13 -12
- data/lib/rouge/lexers/protobuf.rb +23 -22
- data/lib/rouge/lexers/puppet.rb +33 -32
- data/lib/rouge/lexers/python.rb +124 -99
- data/lib/rouge/lexers/q.rb +17 -14
- data/lib/rouge/lexers/qml.rb +13 -12
- data/lib/rouge/lexers/r.rb +13 -13
- data/lib/rouge/lexers/racket.rb +47 -22
- data/lib/rouge/lexers/reasonml.rb +65 -0
- data/lib/rouge/lexers/rego.rb +45 -0
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/ruby.rb +88 -71
- data/lib/rouge/lexers/rust.rb +45 -44
- data/lib/rouge/lexers/sas.rb +563 -0
- data/lib/rouge/lexers/sass.rb +9 -8
- data/lib/rouge/lexers/sass/common.rb +41 -40
- data/lib/rouge/lexers/scala.rb +67 -40
- data/lib/rouge/lexers/scheme.rb +19 -18
- data/lib/rouge/lexers/scss.rb +4 -3
- data/lib/rouge/lexers/sed.rb +31 -30
- data/lib/rouge/lexers/shell.rb +67 -55
- data/lib/rouge/lexers/sieve.rb +10 -9
- data/lib/rouge/lexers/slice.rb +32 -0
- data/lib/rouge/lexers/slim.rb +27 -26
- data/lib/rouge/lexers/smalltalk.rb +34 -33
- data/lib/rouge/lexers/smarty.rb +20 -19
- data/lib/rouge/lexers/sml.rb +68 -67
- data/lib/rouge/lexers/solidity.rb +185 -0
- data/lib/rouge/lexers/sparql.rb +129 -0
- data/lib/rouge/lexers/sqf.rb +109 -0
- data/lib/rouge/lexers/sqf/commands.rb +15 -0
- data/lib/rouge/lexers/sql.rb +47 -26
- data/lib/rouge/lexers/supercollider.rb +116 -0
- data/lib/rouge/lexers/swift.rb +50 -45
- data/lib/rouge/lexers/tap.rb +22 -20
- data/lib/rouge/lexers/tcl.rb +28 -27
- data/lib/rouge/lexers/terraform.rb +128 -0
- data/lib/rouge/lexers/tex.rb +20 -19
- data/lib/rouge/lexers/toml.rb +59 -20
- data/lib/rouge/lexers/tsx.rb +1 -0
- data/lib/rouge/lexers/ttcn3.rb +119 -0
- data/lib/rouge/lexers/tulip.rb +38 -36
- data/lib/rouge/lexers/turtle.rb +36 -38
- data/lib/rouge/lexers/twig.rb +1 -0
- data/lib/rouge/lexers/typescript.rb +12 -0
- data/lib/rouge/lexers/typescript/common.rb +1 -0
- data/lib/rouge/lexers/vala.rb +19 -18
- data/lib/rouge/lexers/varnish.rb +168 -0
- data/lib/rouge/lexers/vb.rb +28 -27
- data/lib/rouge/lexers/verilog.rb +27 -28
- data/lib/rouge/lexers/vhdl.rb +13 -12
- data/lib/rouge/lexers/viml.rb +15 -14
- data/lib/rouge/lexers/viml/keywords.rb +2 -0
- data/lib/rouge/lexers/vue.rb +19 -12
- data/lib/rouge/lexers/wollok.rb +27 -26
- data/lib/rouge/lexers/xml.rb +18 -21
- data/lib/rouge/lexers/xojo.rb +61 -0
- data/lib/rouge/lexers/xpath.rb +332 -0
- data/lib/rouge/lexers/xquery.rb +145 -0
- data/lib/rouge/lexers/yaml.rb +64 -61
- data/lib/rouge/lexers/yang.rb +147 -0
- data/lib/rouge/plugins/redcarpet.rb +9 -2
- data/lib/rouge/regex_lexer.rb +27 -25
- data/lib/rouge/template_lexer.rb +1 -0
- data/lib/rouge/tex_theme_renderer.rb +132 -0
- data/lib/rouge/text_analyzer.rb +1 -0
- data/lib/rouge/theme.rb +5 -0
- data/lib/rouge/themes/base16.rb +1 -0
- data/lib/rouge/themes/bw.rb +41 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +1 -0
- data/lib/rouge/themes/igor_pro.rb +1 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/themes/molokai.rb +1 -0
- data/lib/rouge/themes/monokai.rb +1 -0
- data/lib/rouge/themes/monokai_sublime.rb +4 -1
- data/lib/rouge/themes/pastie.rb +2 -1
- data/lib/rouge/themes/thankful_eyes.rb +2 -1
- data/lib/rouge/themes/tulip.rb +2 -1
- data/lib/rouge/token.rb +31 -22
- data/lib/rouge/util.rb +3 -2
- data/lib/rouge/version.rb +2 -1
- data/rouge.gemspec +6 -3
- metadata +136 -8
- data/lib/rouge/lexers/apache/keywords.yml +0 -764
- data/lib/rouge/lexers/lasso/keywords.yml +0 -446
data/lib/rouge/lexers/scss.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -12,10 +13,10 @@ module Rouge
|
|
12
13
|
mimetypes 'text/x-scss'
|
13
14
|
|
14
15
|
state :root do
|
15
|
-
rule /\s+/, Text
|
16
|
+
rule %r/\s+/, Text
|
16
17
|
rule %r(//.*?$), Comment::Single
|
17
18
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
18
|
-
rule /@import\b/, Keyword, :value
|
19
|
+
rule %r/@import\b/, Keyword, :value
|
19
20
|
|
20
21
|
mixin :content_common
|
21
22
|
|
@@ -26,7 +27,7 @@ module Rouge
|
|
26
27
|
end
|
27
28
|
|
28
29
|
state :end_section do
|
29
|
-
rule /\n/, Text
|
30
|
+
rule %r/\n/, Text
|
30
31
|
rule(/[;{}]/) { token Punctuation; reset_stack }
|
31
32
|
end
|
32
33
|
end
|
data/lib/rouge/lexers/sed.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -16,15 +17,15 @@ module Rouge
|
|
16
17
|
|
17
18
|
class Regex < RegexLexer
|
18
19
|
state :root do
|
19
|
-
rule /\\./, Str::Escape
|
20
|
-
rule /\[/, Punctuation, :brackets
|
21
|
-
rule /[$^.*]/, Operator
|
22
|
-
rule /[()]/, Punctuation
|
23
|
-
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
|
24
25
|
end
|
25
26
|
|
26
27
|
state :brackets do
|
27
|
-
rule /\^/ do
|
28
|
+
rule %r/\^/ do
|
28
29
|
token Punctuation
|
29
30
|
goto :brackets_int
|
30
31
|
end
|
@@ -34,17 +35,17 @@ module Rouge
|
|
34
35
|
|
35
36
|
state :brackets_int do
|
36
37
|
# ranges
|
37
|
-
rule /.-./, Name::Variable
|
38
|
-
rule /\]/, Punctuation, :pop!
|
39
|
-
rule /./, Str::Regex
|
38
|
+
rule %r/.-./, Name::Variable
|
39
|
+
rule %r/\]/, Punctuation, :pop!
|
40
|
+
rule %r/./, Str::Regex
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
class Replacement < RegexLexer
|
44
45
|
state :root do
|
45
|
-
rule /\\./m, Str::Escape
|
46
|
-
rule /&/, Operator
|
47
|
-
rule /[^\\&]+/m, Text
|
46
|
+
rule %r/\\./m, Str::Escape
|
47
|
+
rule %r/&/, Operator
|
48
|
+
rule %r/[^\\&]+/m, Text
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
@@ -59,7 +60,7 @@ module Rouge
|
|
59
60
|
start { regex.reset!; replacement.reset! }
|
60
61
|
|
61
62
|
state :whitespace do
|
62
|
-
rule /\s+/m, Text
|
63
|
+
rule %r/\s+/m, Text
|
63
64
|
rule(/#.*?\n/) { token Comment; reset_stack }
|
64
65
|
rule(/\n/) { token Text; reset_stack }
|
65
66
|
rule(/;/) { token Punctuation; reset_stack }
|
@@ -75,7 +76,7 @@ module Rouge
|
|
75
76
|
mixin :whitespace
|
76
77
|
|
77
78
|
# subst and transliteration
|
78
|
-
rule /(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
79
|
+
rule %r/(s)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
79
80
|
token Keyword, m[1]
|
80
81
|
token Punctuation, m[2]
|
81
82
|
delegate regex, m[3]
|
@@ -87,7 +88,7 @@ module Rouge
|
|
87
88
|
goto :flags
|
88
89
|
end
|
89
90
|
|
90
|
-
rule /(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
91
|
+
rule %r/(y)(.)(#{edot}*?)(\2)(#{edot}*?)(\2)/m do |m|
|
91
92
|
token Keyword, m[1]
|
92
93
|
token Punctuation, m[2]
|
93
94
|
delegate replacement, m[3]
|
@@ -99,29 +100,29 @@ module Rouge
|
|
99
100
|
end
|
100
101
|
|
101
102
|
# commands that take a text segment as an argument
|
102
|
-
rule /([aic])(\s*)/ do
|
103
|
+
rule %r/([aic])(\s*)/ do
|
103
104
|
groups Keyword, Text; goto :text
|
104
105
|
end
|
105
106
|
|
106
|
-
rule /[pd]/, Keyword
|
107
|
+
rule %r/[pd]/, Keyword
|
107
108
|
|
108
109
|
# commands that take a number argument
|
109
|
-
rule /([qQl])(\s+)(\d+)/i do
|
110
|
+
rule %r/([qQl])(\s+)(\d+)/i do
|
110
111
|
groups Keyword, Text, Num
|
111
112
|
pop!
|
112
113
|
end
|
113
114
|
|
114
115
|
# no-argument commands
|
115
|
-
rule /[={}dDgGhHlnpPqx]/, Keyword, :pop!
|
116
|
+
rule %r/[={}dDgGhHlnpPqx]/, Keyword, :pop!
|
116
117
|
|
117
118
|
# commands that take a filename argument
|
118
|
-
rule /([rRwW])(\s+)(\S+)/ do
|
119
|
+
rule %r/([rRwW])(\s+)(\S+)/ do
|
119
120
|
groups Keyword, Text, Name
|
120
121
|
pop!
|
121
122
|
end
|
122
123
|
|
123
124
|
# commands that take a label argument
|
124
|
-
rule /([:btT])(\s+)(\S+)/ do
|
125
|
+
rule %r/([:btT])(\s+)(\S+)/ do
|
125
126
|
groups Keyword, Text, Name::Label
|
126
127
|
pop!
|
127
128
|
end
|
@@ -132,15 +133,15 @@ module Rouge
|
|
132
133
|
|
133
134
|
### address ranges ###
|
134
135
|
addr_tok = Keyword::Namespace
|
135
|
-
rule /\d+/, addr_tok
|
136
|
-
rule /[$,~+!]/, addr_tok
|
136
|
+
rule %r/\d+/, addr_tok
|
137
|
+
rule %r/[$,~+!]/, addr_tok
|
137
138
|
|
138
139
|
rule %r((/)((?:\\.|.)*?)(/)) do |m|
|
139
140
|
token addr_tok, m[1]; delegate regex, m[2]; token addr_tok, m[3]
|
140
141
|
end
|
141
142
|
|
142
143
|
# alternate regex rage delimiters
|
143
|
-
rule %r((\\)(.)(
|
144
|
+
rule %r((\\)(.)((?:\\.|.)*?)(\2)) do |m|
|
144
145
|
token addr_tok, m[1] + m[2]
|
145
146
|
delegate regex, m[3]
|
146
147
|
token addr_tok, m[4]
|
@@ -150,18 +151,18 @@ module Rouge
|
|
150
151
|
end
|
151
152
|
|
152
153
|
state :text do
|
153
|
-
rule /[^\\\n]+/, Str
|
154
|
-
rule /\\\n/, Str::Escape
|
155
|
-
rule /\\/, Str
|
156
|
-
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!
|
157
158
|
end
|
158
159
|
|
159
160
|
state :flags do
|
160
|
-
rule /[gp]+/, Keyword, :pop!
|
161
|
+
rule %r/[gp]+/, Keyword, :pop!
|
161
162
|
|
162
163
|
# writing to a file with the subst command.
|
163
164
|
# who'da thunk...?
|
164
|
-
rule /([wW])(\s+)(\S+)/ do
|
165
|
+
rule %r/([wW])(\s+)(\S+)/ do
|
165
166
|
token Keyword; token Text; token Name
|
166
167
|
end
|
167
168
|
|
data/lib/rouge/lexers/shell.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -8,10 +9,12 @@ module Rouge
|
|
8
9
|
|
9
10
|
tag 'shell'
|
10
11
|
aliases 'bash', 'zsh', 'ksh', 'sh'
|
11
|
-
filenames '*.sh', '*.bash', '*.zsh', '*.ksh',
|
12
|
-
'.
|
12
|
+
filenames '*.sh', '*.bash', '*.zsh', '*.ksh', '.bashrc', '.zshrc',
|
13
|
+
'.kshrc', '.profile', 'APKBUILD', 'PKGBUILD', '*.ebuild',
|
14
|
+
'*.eclass', '*.exheres-0', '*.exlib'
|
13
15
|
|
14
|
-
mimetypes 'application/x-sh', 'application/x-shellscript'
|
16
|
+
mimetypes 'application/x-sh', 'application/x-shellscript', 'text/x-sh',
|
17
|
+
'text/x-shellscript'
|
15
18
|
|
16
19
|
def self.detect?(text)
|
17
20
|
return true if text.shebang?(/(ba|z|k)?sh/)
|
@@ -43,25 +46,25 @@ module Rouge
|
|
43
46
|
).join('|')
|
44
47
|
|
45
48
|
state :basic do
|
46
|
-
rule /#.*$/, Comment
|
49
|
+
rule %r/#.*$/, Comment
|
47
50
|
|
48
|
-
rule /\b(#{KEYWORDS})\s*\b/, Keyword
|
49
|
-
rule /\bcase\b/, Keyword, :case
|
51
|
+
rule %r/\b(#{KEYWORDS})\s*\b/, Keyword
|
52
|
+
rule %r/\bcase\b/, Keyword, :case
|
50
53
|
|
51
|
-
rule /\b(#{BUILTINS})\s*\b(?!(\.|-))/, Name::Builtin
|
52
|
-
rule /[.](?=\s)/, Name::Builtin
|
54
|
+
rule %r/\b(#{BUILTINS})\s*\b(?!(\.|-))/, Name::Builtin
|
55
|
+
rule %r/[.](?=\s)/, Name::Builtin
|
53
56
|
|
54
|
-
rule /(\b\w+)(=)/ do
|
57
|
+
rule %r/(\b\w+)(=)/ do
|
55
58
|
groups Name::Variable, Operator
|
56
59
|
end
|
57
60
|
|
58
|
-
rule /[\[\]{}()!=>]/, Operator
|
59
|
-
rule /&&|\|\|/, Operator
|
61
|
+
rule %r/[\[\]{}()!=>]/, Operator
|
62
|
+
rule %r/&&|\|\|/, Operator
|
60
63
|
|
61
64
|
# here-string
|
62
|
-
rule /<<</, Operator
|
65
|
+
rule %r/<<</, Operator
|
63
66
|
|
64
|
-
rule /(<<-?)(\s*)(
|
67
|
+
rule %r/(<<-?)(\s*)(['"]?)(\\?)(\w+)(\3)/ do |m|
|
65
68
|
groups Operator, Text, Str::Heredoc, Str::Heredoc, Name::Constant, Str::Heredoc
|
66
69
|
@heredocstr = Regexp.escape(m[5])
|
67
70
|
push :heredoc
|
@@ -69,14 +72,14 @@ module Rouge
|
|
69
72
|
end
|
70
73
|
|
71
74
|
state :heredoc do
|
72
|
-
rule /\n/, Str::Heredoc, :heredoc_nl
|
73
|
-
rule /[^$\n]+/, Str::Heredoc
|
75
|
+
rule %r/\n/, Str::Heredoc, :heredoc_nl
|
76
|
+
rule %r/[^$\n\\]+/, Str::Heredoc
|
74
77
|
mixin :interp
|
75
|
-
rule /[$]/, Str::Heredoc
|
78
|
+
rule %r/[$]/, Str::Heredoc
|
76
79
|
end
|
77
80
|
|
78
81
|
state :heredoc_nl do
|
79
|
-
rule /\s*(\w+)\s*\n/ do |m|
|
82
|
+
rule %r/\s*(\w+)\s*\n/ do |m|
|
80
83
|
if m[1] == @heredocstr
|
81
84
|
token Name::Constant
|
82
85
|
pop! 2
|
@@ -92,92 +95,101 @@ module Rouge
|
|
92
95
|
state :double_quotes do
|
93
96
|
# NB: "abc$" is literally the string abc$.
|
94
97
|
# Here we prevent :interp from interpreting $" as a variable.
|
95
|
-
rule /(?:\$#?)?"/, Str::Double, :pop!
|
98
|
+
rule %r/(?:\$#?)?"/, Str::Double, :pop!
|
96
99
|
mixin :interp
|
97
|
-
rule /[^"`\\$]+/, Str::Double
|
100
|
+
rule %r/[^"`\\$]+/, Str::Double
|
98
101
|
end
|
99
102
|
|
100
103
|
state :ansi_string do
|
101
|
-
rule /\\./, Str::Escape
|
102
|
-
rule /[^\\']+/, Str::Single
|
104
|
+
rule %r/\\./, Str::Escape
|
105
|
+
rule %r/[^\\']+/, Str::Single
|
103
106
|
mixin :single_quotes
|
104
107
|
end
|
105
108
|
|
106
109
|
state :single_quotes do
|
107
|
-
rule /'/, Str::Single, :pop!
|
108
|
-
rule /[^']+/, Str::Single
|
110
|
+
rule %r/'/, Str::Single, :pop!
|
111
|
+
rule %r/[^']+/, Str::Single
|
109
112
|
end
|
110
113
|
|
111
114
|
state :data do
|
112
|
-
rule /\s+/, Text
|
113
|
-
rule /\\./, Str::Escape
|
114
|
-
rule /\$?"/, Str::Double, :double_quotes
|
115
|
-
rule /\$'/, Str::Single, :ansi_string
|
115
|
+
rule %r/\s+/, Text
|
116
|
+
rule %r/\\./, Str::Escape
|
117
|
+
rule %r/\$?"/, Str::Double, :double_quotes
|
118
|
+
rule %r/\$'/, Str::Single, :ansi_string
|
116
119
|
|
117
120
|
# single quotes are much easier than double quotes - we can
|
118
121
|
# literally just scan until the next single quote.
|
119
122
|
# POSIX: Enclosing characters in single-quotes ( '' )
|
120
123
|
# shall preserve the literal value of each character within the
|
121
124
|
# single-quotes. A single-quote cannot occur within single-quotes.
|
122
|
-
rule /'/, Str::Single, :single_quotes
|
125
|
+
rule %r/'/, Str::Single, :single_quotes
|
123
126
|
|
124
|
-
rule /\*/, Keyword
|
127
|
+
rule %r/\*/, Keyword
|
125
128
|
|
126
|
-
rule /;/, Punctuation
|
129
|
+
rule %r/;/, Punctuation
|
127
130
|
|
128
|
-
rule /--?[\w-]+/, Name::Tag
|
129
|
-
rule /[^=\*\s{}()$"'`;\\<]+/, Text
|
130
|
-
rule /\d+(?= |\Z)/, Num
|
131
|
-
rule /</, Text
|
131
|
+
rule %r/--?[\w-]+/, Name::Tag
|
132
|
+
rule %r/[^=\*\s{}()$"'`;\\<]+/, Text
|
133
|
+
rule %r/\d+(?= |\Z)/, Num
|
134
|
+
rule %r/</, Text
|
132
135
|
mixin :interp
|
133
136
|
end
|
134
137
|
|
135
138
|
state :curly do
|
136
|
-
rule /}/, Keyword, :pop!
|
137
|
-
rule /:-/, Keyword
|
138
|
-
rule /[a-zA-Z0-9_]+/, Name::Variable
|
139
|
-
rule /[^}:"`'$]+/, Punctuation
|
139
|
+
rule %r/}/, Keyword, :pop!
|
140
|
+
rule %r/:-/, Keyword
|
141
|
+
rule %r/[a-zA-Z0-9_]+/, Name::Variable
|
142
|
+
rule %r/[^}:"`'$]+/, Punctuation
|
140
143
|
mixin :root
|
141
144
|
end
|
142
145
|
|
143
|
-
state
|
144
|
-
|
146
|
+
# the state inside $(...)
|
147
|
+
state :paren_interp do
|
148
|
+
rule %r/\)/, Str::Interpol, :pop!
|
149
|
+
rule %r/\(/, Operator, :paren_inner
|
150
|
+
mixin :root
|
151
|
+
end
|
152
|
+
|
153
|
+
# used to balance parentheses inside interpolation
|
154
|
+
state :paren_inner do
|
155
|
+
rule %r/\(/, Operator, :push
|
156
|
+
rule %r/\)/, Operator, :pop!
|
145
157
|
mixin :root
|
146
158
|
end
|
147
159
|
|
148
160
|
state :math do
|
149
|
-
rule /\)\)/, Keyword, :pop!
|
161
|
+
rule %r/\)\)/, Keyword, :pop!
|
150
162
|
rule %r([-+*/%^|&!]|\*\*|\|\|), Operator
|
151
|
-
rule /\d+(#\w+)?/, Num
|
163
|
+
rule %r/\d+(#\w+)?/, Num
|
152
164
|
mixin :root
|
153
165
|
end
|
154
166
|
|
155
167
|
state :case do
|
156
|
-
rule /\besac\b/, Keyword, :pop!
|
157
|
-
rule /\|/, Punctuation
|
158
|
-
rule /\)/, Punctuation, :case_stanza
|
168
|
+
rule %r/\besac\b/, Keyword, :pop!
|
169
|
+
rule %r/\|/, Punctuation
|
170
|
+
rule %r/\)/, Punctuation, :case_stanza
|
159
171
|
mixin :root
|
160
172
|
end
|
161
173
|
|
162
174
|
state :case_stanza do
|
163
|
-
rule /;;/, Punctuation, :pop!
|
175
|
+
rule %r/;;/, Punctuation, :pop!
|
164
176
|
mixin :root
|
165
177
|
end
|
166
178
|
|
167
179
|
state :backticks do
|
168
|
-
rule /`/, Str::Backtick, :pop!
|
180
|
+
rule %r/`/, Str::Backtick, :pop!
|
169
181
|
mixin :root
|
170
182
|
end
|
171
183
|
|
172
184
|
state :interp do
|
173
|
-
rule /\\$/, Str::Escape # line continuation
|
174
|
-
rule /\\./, Str::Escape
|
175
|
-
rule /\$\(\(/, Keyword, :math
|
176
|
-
rule /\$\(/,
|
177
|
-
rule /\${#?/, Keyword, :curly
|
178
|
-
rule /`/, Str::Backtick, :backticks
|
179
|
-
rule /\$#?(\w+|.)/, Name::Variable
|
180
|
-
rule /\$[*@]/, Name::Variable
|
185
|
+
rule %r/\\$/, Str::Escape # line continuation
|
186
|
+
rule %r/\\./, Str::Escape
|
187
|
+
rule %r/\$\(\(/, Keyword, :math
|
188
|
+
rule %r/\$\(/, Str::Interpol, :paren_interp
|
189
|
+
rule %r/\${#?/, Keyword, :curly
|
190
|
+
rule %r/`/, Str::Backtick, :backticks
|
191
|
+
rule %r/\$#?(\w+|.)/, Name::Variable
|
192
|
+
rule %r/\$[*@]/, Name::Variable
|
181
193
|
end
|
182
194
|
|
183
195
|
state :root do
|
data/lib/rouge/lexers/sieve.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -56,23 +57,23 @@ module Rouge
|
|
56
57
|
end
|
57
58
|
|
58
59
|
state :comments_and_whitespace do
|
59
|
-
rule /\s+/, Text
|
60
|
-
rule %r(
|
60
|
+
rule %r/\s+/, Text
|
61
|
+
rule %r(#.*), Comment::Single
|
61
62
|
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
|
62
63
|
end
|
63
64
|
|
64
65
|
state :string do
|
65
|
-
rule /\\./, Str::Escape
|
66
|
-
rule /"/, Str::Double, :pop!
|
66
|
+
rule %r/\\./, Str::Escape
|
67
|
+
rule %r/"/, Str::Double, :pop!
|
67
68
|
# Variables Extension (rfc5229)
|
68
|
-
rule /\${(?:[0-9][.0-9]*|[a-zA-Z_][.a-zA-Z0-9_]*)}/, Str::Interpol
|
69
|
-
rule /./, Str::Double
|
69
|
+
rule %r/\${(?:[0-9][.0-9]*|[a-zA-Z_][.a-zA-Z0-9_]*)}/, Str::Interpol
|
70
|
+
rule %r/./, Str::Double
|
70
71
|
end
|
71
72
|
|
72
73
|
state :root do
|
73
74
|
mixin :comments_and_whitespace
|
74
75
|
|
75
|
-
rule /[\[\](),;{}]/, Punctuation
|
76
|
+
rule %r/[\[\](),;{}]/, Punctuation
|
76
77
|
|
77
78
|
rule id do |m|
|
78
79
|
if self.class.controls.include? m[0]
|
@@ -88,8 +89,8 @@ module Rouge
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
rule /"/, Str::Double, :string
|
92
|
-
rule /[0-9]+[KMG]/, Num::Integer
|
92
|
+
rule %r/"/, Str::Double, :string
|
93
|
+
rule %r/[0-9]+[KMG]/, Num::Integer
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
load_lexer 'c.rb'
|
7
|
+
|
8
|
+
class Slice < C
|
9
|
+
tag 'slice'
|
10
|
+
filenames '*.ice'
|
11
|
+
mimetypes 'text/slice'
|
12
|
+
|
13
|
+
title "Slice"
|
14
|
+
desc "Specification Language for Ice (doc.zeroc.com)"
|
15
|
+
|
16
|
+
def self.keywords
|
17
|
+
@keywords ||= Set.new %w(
|
18
|
+
extends implements enum interface struct class module dictionary
|
19
|
+
const optional out throws exception local idempotent sequence
|
20
|
+
|
21
|
+
Object LocalObject Value
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.keywords_type
|
26
|
+
@keywords_type ||= Set.new %w(
|
27
|
+
bool string byte long float double int void short
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|