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/jinja.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
|
@@ -36,82 +37,89 @@ module Rouge
|
|
36
37
|
|
37
38
|
state :root do
|
38
39
|
# Comments
|
39
|
-
rule /{#/, Comment, :comment
|
40
|
+
rule %r/{#/, Comment, :comment
|
41
|
+
rule %r/##.*/, Comment
|
40
42
|
|
41
43
|
# Statements
|
42
|
-
rule /\{\%/ do
|
44
|
+
rule %r/\{\%/ do
|
43
45
|
token Comment::Preproc
|
44
46
|
push :statement
|
45
47
|
end
|
46
48
|
|
47
49
|
# Expressions
|
48
|
-
rule /\{\{/ do
|
50
|
+
rule %r/\{\{/ do
|
49
51
|
token Comment::Preproc
|
50
52
|
push :expression
|
51
53
|
end
|
52
54
|
|
53
|
-
rule(/(.+?)(?=\\|{{|{%|{
|
55
|
+
rule(/(.+?)(?=\\|{{|{%|{#|##)/m) { delegate parent }
|
54
56
|
rule(/.+/m) { delegate parent }
|
55
57
|
end
|
56
58
|
|
57
59
|
state :filter do
|
58
60
|
# Filters are called like variable|foo(arg1, ...)
|
59
|
-
rule /(
|
61
|
+
rule %r/(\|\s*)(\w+)/ do
|
60
62
|
groups Operator, Name::Function
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
66
|
state :function do
|
65
|
-
rule /(\w+)(\()/ do
|
67
|
+
rule %r/(\w+)(\()/ do
|
66
68
|
groups Name::Function, Punctuation
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
72
|
state :text do
|
71
|
-
rule /\s+/m, Text
|
73
|
+
rule %r/\s+/m, Text
|
72
74
|
end
|
73
75
|
|
74
76
|
state :literal do
|
75
77
|
# Strings
|
76
|
-
rule /"(\\.|.)*?"/, Str::Double
|
77
|
-
rule /'(\\.|.)*?'/, Str::Single
|
78
|
+
rule %r/"(\\.|.)*?"/, Str::Double
|
79
|
+
rule %r/'(\\.|.)*?'/, Str::Single
|
78
80
|
|
79
81
|
# Numbers
|
80
|
-
rule /\d+(?=}\s)/, Num
|
82
|
+
rule %r/\d+(?=}\s)/, Num
|
81
83
|
|
82
84
|
# Arithmetic operators (+, -, *, **, //, /)
|
83
85
|
# TODO : implement modulo (%)
|
84
|
-
rule /(
|
86
|
+
rule %r/(\+|\-|\*|\/\/?|\*\*?|=)/, Operator
|
85
87
|
|
86
88
|
# Comparisons operators (<=, <, >=, >, ==, ===, !=)
|
87
|
-
rule /(<=?|>=?|===?|!=)/, Operator
|
89
|
+
rule %r/(<=?|>=?|===?|!=)/, Operator
|
88
90
|
|
89
91
|
# Punctuation (the comma, [], ())
|
90
|
-
rule /,/, Punctuation
|
91
|
-
rule /\[/, Punctuation
|
92
|
-
rule /\]/, Punctuation
|
93
|
-
rule /\(/, Punctuation
|
94
|
-
rule /\)/, Punctuation
|
92
|
+
rule %r/,/, Punctuation
|
93
|
+
rule %r/\[/, Punctuation
|
94
|
+
rule %r/\]/, Punctuation
|
95
|
+
rule %r/\(/, Punctuation
|
96
|
+
rule %r/\)/, Punctuation
|
95
97
|
end
|
96
98
|
|
97
99
|
state :comment do
|
98
|
-
rule
|
100
|
+
rule %r/[^#]+/m, Comment
|
99
101
|
rule(/#}/) { token Comment; pop! }
|
102
|
+
rule %r/#/, Comment
|
100
103
|
end
|
101
104
|
|
102
105
|
state :expression do
|
103
|
-
rule /\w+\.?/m, Name::Variable
|
106
|
+
rule %r/\w+\.?/m, Name::Variable
|
104
107
|
|
105
108
|
mixin :filter
|
106
109
|
mixin :function
|
107
110
|
mixin :literal
|
108
111
|
mixin :text
|
109
112
|
|
110
|
-
rule /%}|}}/, Comment::Preproc, :pop!
|
113
|
+
rule %r/%}|}}/, Comment::Preproc, :pop!
|
111
114
|
end
|
112
115
|
|
113
116
|
state :statement do
|
114
|
-
rule /(\
|
117
|
+
rule %r/(raw|verbatim)(\s+)(\%\})/ do
|
118
|
+
groups Keyword, Text, Comment::Preproc
|
119
|
+
goto :raw
|
120
|
+
end
|
121
|
+
|
122
|
+
rule %r/(\w+\.?)/ do |m|
|
115
123
|
if self.class.keywords.include?(m[0])
|
116
124
|
groups Keyword
|
117
125
|
elsif self.class.pseudo_keywords.include?(m[0])
|
@@ -130,7 +138,16 @@ module Rouge
|
|
130
138
|
mixin :literal
|
131
139
|
mixin :text
|
132
140
|
|
133
|
-
rule /\%\}/, Comment::Preproc, :pop!
|
141
|
+
rule %r/\%\}/, Comment::Preproc, :pop!
|
142
|
+
end
|
143
|
+
|
144
|
+
state :raw do
|
145
|
+
rule %r{(\{\%)(\s+)(endverbatim|endraw)(\s+)(\%\})} do
|
146
|
+
groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
|
147
|
+
pop!
|
148
|
+
end
|
149
|
+
|
150
|
+
rule %r/(.+?)/m, Text
|
134
151
|
end
|
135
152
|
end
|
136
153
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class JSL < RegexLexer
|
7
|
+
title "JSL"
|
8
|
+
desc "The JMP Scripting Language (JSL) (jmp.com)"
|
9
|
+
|
10
|
+
tag 'jsl'
|
11
|
+
filenames '*.jsl'
|
12
|
+
|
13
|
+
state :root do
|
14
|
+
rule %r/\s+/m, Text::Whitespace
|
15
|
+
|
16
|
+
rule %r(//.*?$), Comment::Single
|
17
|
+
rule %r(/\*.*?\*/)m, Comment::Multiline
|
18
|
+
|
19
|
+
# messages
|
20
|
+
rule %r/(<<)(.*?)(\(|;)/ do |m|
|
21
|
+
groups Operator, Name::Function, Punctuation
|
22
|
+
end
|
23
|
+
|
24
|
+
# covers built-in and custom functions
|
25
|
+
rule %r/([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
26
|
+
groups Keyword, Punctuation
|
27
|
+
end
|
28
|
+
|
29
|
+
rule %r/\b[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+|\.)(?:e[+-]?[0-9]+)?i?\b/i, Num
|
30
|
+
|
31
|
+
rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date
|
32
|
+
|
33
|
+
rule %r/::[a-z_][\w\s'%.\\]*/i, Name::Variable
|
34
|
+
rule %r/:\w+/, Name
|
35
|
+
rule %r/[a-z_][\w\s'%.\\]*/i, Name::Variable
|
36
|
+
rule %r/"(?:\\!"|[^"])*?"n/m, Name::Variable
|
37
|
+
|
38
|
+
rule %r/(")(\\\[)(.*?)(\]\\)(")/m do
|
39
|
+
groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double # escaped string
|
40
|
+
end
|
41
|
+
rule %r/"/, Str::Double, :dq
|
42
|
+
|
43
|
+
rule %r/[-+*\/!%&<>\|=:]/, Operator
|
44
|
+
rule %r/[\[\](){},;]/, Punctuation
|
45
|
+
end
|
46
|
+
|
47
|
+
state :dq do
|
48
|
+
rule %r/\\![btrnNf0\\"]/, Str::Escape
|
49
|
+
rule %r/\\/, Str::Double
|
50
|
+
rule %r/"/, Str::Double, :pop!
|
51
|
+
rule %r/[^\\"]*/m, Str::Double
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/rouge/lexers/json.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -6,23 +7,65 @@ module Rouge
|
|
6
7
|
title 'JSON'
|
7
8
|
desc "JavaScript Object Notation (json.org)"
|
8
9
|
tag 'json'
|
9
|
-
filenames '*.json'
|
10
|
+
filenames '*.json', 'Pipfile.lock'
|
10
11
|
mimetypes 'application/json', 'application/vnd.api+json',
|
11
|
-
'application/hal+json'
|
12
|
+
'application/hal+json', 'application/problem+json',
|
13
|
+
'application/schema+json'
|
14
|
+
|
15
|
+
state :whitespace do
|
16
|
+
rule %r/\s+/, Text::Whitespace
|
17
|
+
end
|
12
18
|
|
13
19
|
state :root do
|
14
|
-
|
15
|
-
rule /
|
16
|
-
rule
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
mixin :whitespace
|
21
|
+
rule %r/{/, Punctuation, :object
|
22
|
+
rule %r/\[/, Punctuation, :array
|
23
|
+
|
24
|
+
mixin :name
|
25
|
+
mixin :value
|
26
|
+
|
27
|
+
# These characters may be invalid but syntax correctness is a non-goal
|
28
|
+
rule %r/[\]}]/, Punctuation
|
29
|
+
end
|
30
|
+
|
31
|
+
state :object do
|
32
|
+
mixin :whitespace
|
33
|
+
mixin :name
|
34
|
+
mixin :value
|
35
|
+
rule %r/}/, Punctuation, :pop!
|
36
|
+
rule %r/,/, Punctuation
|
37
|
+
end
|
38
|
+
|
39
|
+
state :name do
|
40
|
+
rule %r/("(?:\\.|[^"\\\n])*?")(\s*)(:)/ do
|
41
|
+
groups Name::Label, Text::Whitespace, Punctuation
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
state :value do
|
46
|
+
mixin :whitespace
|
47
|
+
mixin :constants
|
48
|
+
rule %r/"/, Str::Double, :string
|
49
|
+
rule %r/\[/, Punctuation, :array
|
50
|
+
rule %r/{/, Punctuation, :object
|
20
51
|
end
|
21
52
|
|
22
53
|
state :string do
|
23
|
-
rule /[^\\"]+/, Str::Double
|
24
|
-
rule /\\./, Str::Escape
|
25
|
-
rule /"/, Str::Double, :pop!
|
54
|
+
rule %r/[^\\"]+/, Str::Double
|
55
|
+
rule %r/\\./, Str::Escape
|
56
|
+
rule %r/"/, Str::Double, :pop!
|
57
|
+
end
|
58
|
+
|
59
|
+
state :array do
|
60
|
+
mixin :value
|
61
|
+
rule %r/\]/, Punctuation, :pop!
|
62
|
+
rule %r/,/, Punctuation
|
63
|
+
end
|
64
|
+
|
65
|
+
state :constants do
|
66
|
+
rule %r/(?:true|false|null)/, Keyword::Constant
|
67
|
+
rule %r/-?(?:0|[1-9]\d*)\.\d+(?:e[+-]?\d+)?/i, Num::Float
|
68
|
+
rule %r/-?(?:0|[1-9]\d*)(?:e[+-]?\d+)?/i, Num::Integer
|
26
69
|
end
|
27
70
|
end
|
28
71
|
end
|
@@ -1,22 +1,25 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
5
6
|
load_lexer 'json.rb'
|
6
7
|
|
7
8
|
class JSONDOC < JSON
|
8
|
-
desc "JavaScript Object Notation with
|
9
|
+
desc "JavaScript Object Notation with extensions for documentation"
|
9
10
|
tag 'json-doc'
|
11
|
+
aliases 'jsonc'
|
10
12
|
|
11
|
-
prepend :
|
12
|
-
rule /([$\w]+)(\s*)(:)/ do
|
13
|
+
prepend :name do
|
14
|
+
rule %r/([$\w]+)(\s*)(:)/ do
|
13
15
|
groups Name::Attribute, Text, Punctuation
|
14
16
|
end
|
17
|
+
end
|
15
18
|
|
19
|
+
prepend :value do
|
16
20
|
rule %r(/[*].*?[*]/), Comment
|
17
|
-
|
18
21
|
rule %r(//.*?$), Comment::Single
|
19
|
-
rule /(\.\.\.)/, Comment::Single
|
22
|
+
rule %r/(\.\.\.)/, Comment::Single
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
data/lib/rouge/lexers/jsonnet.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
|
@@ -6,7 +7,7 @@ module Rouge
|
|
6
7
|
title 'Jsonnet'
|
7
8
|
desc 'An elegant, formally-specified config language for JSON'
|
8
9
|
tag 'jsonnet'
|
9
|
-
filenames '*.jsonnet'
|
10
|
+
filenames '*.jsonnet', '*.libsonnet'
|
10
11
|
mimetypes 'text/x-jsonnet'
|
11
12
|
|
12
13
|
def self.keywords
|
@@ -92,21 +93,21 @@ module Rouge
|
|
92
93
|
identifier = /[a-zA-Z_][a-zA-Z0-9_]*/
|
93
94
|
|
94
95
|
state :root do
|
95
|
-
rule /\s+/, Text
|
96
|
+
rule %r/\s+/, Text
|
96
97
|
rule %r(//.*?$), Comment::Single
|
97
98
|
rule %r(#.*?$), Comment::Single
|
98
99
|
rule %r(/\*.*?\*/)m, Comment::Multiline
|
99
100
|
|
100
|
-
rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
|
101
|
-
rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
|
101
|
+
rule %r/-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
|
102
|
+
rule %r/-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
|
102
103
|
|
103
|
-
rule /[{}:\.,;+\[\]=%\(\)]/, Punctuation
|
104
|
+
rule %r/[{}:\.,;+\[\]=%\(\)]/, Punctuation
|
104
105
|
|
105
|
-
rule /"/, Str, :string_double
|
106
|
-
rule /'/, Str, :string_single
|
107
|
-
rule /\|\|\|/, Str, :string_block
|
106
|
+
rule %r/"/, Str, :string_double
|
107
|
+
rule %r/'/, Str, :string_single
|
108
|
+
rule %r/\|\|\|/, Str, :string_block
|
108
109
|
|
109
|
-
rule /\$/, Keyword
|
110
|
+
rule %r/\$/, Keyword
|
110
111
|
|
111
112
|
rule identifier do |m|
|
112
113
|
if self.class.keywords.include? m[0]
|
@@ -124,27 +125,27 @@ module Rouge
|
|
124
125
|
end
|
125
126
|
|
126
127
|
state :string do
|
127
|
-
rule /\\([\\\/bfnrt]|(u[0-9a-fA-F]{4}))/, Str::Escape
|
128
|
+
rule %r/\\([\\\/bfnrt]|(u[0-9a-fA-F]{4}))/, Str::Escape
|
128
129
|
end
|
129
130
|
|
130
131
|
state :string_double do
|
131
132
|
mixin :string
|
132
|
-
rule /\\"/, Str::Escape
|
133
|
-
rule /"/, Str, :pop!
|
134
|
-
rule /[^\\"]+/, Str
|
133
|
+
rule %r/\\"/, Str::Escape
|
134
|
+
rule %r/"/, Str, :pop!
|
135
|
+
rule %r/[^\\"]+/, Str
|
135
136
|
end
|
136
137
|
|
137
138
|
state :string_single do
|
138
139
|
mixin :string
|
139
|
-
rule /\\'/, Str::Escape
|
140
|
-
rule /'/, Str, :pop!
|
141
|
-
rule /[^\\']+/, Str
|
140
|
+
rule %r/\\'/, Str::Escape
|
141
|
+
rule %r/'/, Str, :pop!
|
142
|
+
rule %r/[^\\']+/, Str
|
142
143
|
end
|
143
144
|
|
144
145
|
state :string_block do
|
145
146
|
mixin :string
|
146
|
-
rule /\|\|\|/, Str, :pop!
|
147
|
-
rule /.*/, Str
|
147
|
+
rule %r/\|\|\|/, Str, :pop!
|
148
|
+
rule %r/.*/, Str
|
148
149
|
end
|
149
150
|
end
|
150
151
|
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class JSP < TemplateLexer
|
7
|
+
desc 'JSP'
|
8
|
+
tag 'jsp'
|
9
|
+
filenames '*.jsp'
|
10
|
+
mimetypes 'text/x-jsp', 'application/x-jsp'
|
11
|
+
|
12
|
+
def initialize(*)
|
13
|
+
super
|
14
|
+
@java = Java.new
|
15
|
+
end
|
16
|
+
|
17
|
+
directives = %w(page include taglib)
|
18
|
+
actions = %w(scriptlet declaration expression)
|
19
|
+
|
20
|
+
state :root do
|
21
|
+
|
22
|
+
rule %r/<%--/, Comment, :jsp_comment
|
23
|
+
|
24
|
+
rule %r/<%@\s*(#{directives.join('|')})\s*/, Name::Tag, :jsp_directive
|
25
|
+
|
26
|
+
rule %r/<jsp:directive\.(#{directives.join('|')})/, Name::Tag, :jsp_directive2
|
27
|
+
|
28
|
+
rule %r/<jsp:(#{actions.join('|')})>/, Name::Tag, :jsp_expression
|
29
|
+
|
30
|
+
# start of tag, e.g. <c:if>
|
31
|
+
rule %r/<[a-zA-Z]*:[a-zA-Z]*\s*/, Name::Tag, :jsp_tag
|
32
|
+
|
33
|
+
# end of tag, e.g. </c:if>
|
34
|
+
rule %r(</[a-zA-Z]*:[a-zA-Z]*>), Name::Tag
|
35
|
+
|
36
|
+
rule %r/<%[!=]?/, Name::Tag, :jsp_expression2
|
37
|
+
|
38
|
+
# fallback to HTML
|
39
|
+
rule(/(.+?)(?=(<%|<\/?[a-zA-Z]*:))/m) { delegate parent }
|
40
|
+
rule(/.+/m) { delegate parent }
|
41
|
+
end
|
42
|
+
|
43
|
+
state :jsp_comment do
|
44
|
+
rule %r/(--%>)/, Comment, :pop!
|
45
|
+
rule %r/./m, Comment
|
46
|
+
end
|
47
|
+
|
48
|
+
state :jsp_directive do
|
49
|
+
rule %r/(%>)/, Name::Tag, :pop!
|
50
|
+
mixin :attributes
|
51
|
+
rule(/(.+?)(?=%>)/m) { delegate parent }
|
52
|
+
end
|
53
|
+
|
54
|
+
state :jsp_directive2 do
|
55
|
+
rule %r!(/>)!, Name::Tag, :pop!
|
56
|
+
mixin :attributes
|
57
|
+
rule(/(.+?)(?=\/>)/m) { delegate parent }
|
58
|
+
end
|
59
|
+
|
60
|
+
state :jsp_expression do
|
61
|
+
rule %r/<\/jsp:(#{actions.join('|')})>/, Name::Tag, :pop!
|
62
|
+
mixin :attributes
|
63
|
+
rule(/[^<\/]+/) { delegate @java }
|
64
|
+
end
|
65
|
+
|
66
|
+
state :jsp_expression2 do
|
67
|
+
rule %r/%>/, Name::Tag, :pop!
|
68
|
+
rule(/[^%>]+/) { delegate @java }
|
69
|
+
end
|
70
|
+
|
71
|
+
state :jsp_tag do
|
72
|
+
rule %r/\/?>/, Name::Tag, :pop!
|
73
|
+
mixin :attributes
|
74
|
+
rule(/(.+?)(?=\/?>)/m) { delegate parent }
|
75
|
+
end
|
76
|
+
|
77
|
+
state :attributes do
|
78
|
+
rule %r/\s*[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
|
79
|
+
end
|
80
|
+
|
81
|
+
state :attr do
|
82
|
+
rule %r/"/ do
|
83
|
+
token Str
|
84
|
+
goto :double_quotes
|
85
|
+
end
|
86
|
+
|
87
|
+
rule %r/'/ do
|
88
|
+
token Str
|
89
|
+
goto :single_quotes
|
90
|
+
end
|
91
|
+
|
92
|
+
rule %r/[^\s>]+/, Str, :pop!
|
93
|
+
end
|
94
|
+
|
95
|
+
state :double_quotes do
|
96
|
+
rule %r/"/, Str, :pop!
|
97
|
+
rule %r/\$\{/, Str::Interpol, :jsp_interp
|
98
|
+
rule %r/[^"]+/, Str
|
99
|
+
end
|
100
|
+
|
101
|
+
state :single_quotes do
|
102
|
+
rule %r/'/, Str, :pop!
|
103
|
+
rule %r/\$\{/, Str::Interpol, :jsp_interp
|
104
|
+
rule %r/[^']+/, Str
|
105
|
+
end
|
106
|
+
|
107
|
+
state :jsp_interp do
|
108
|
+
rule %r/\}/, Str::Interpol, :pop!
|
109
|
+
rule %r/'/, Literal, :jsp_interp_literal_start
|
110
|
+
rule(/[^'\}]+/) { delegate @java }
|
111
|
+
end
|
112
|
+
|
113
|
+
state :jsp_interp_literal_start do
|
114
|
+
rule %r/'/, Literal, :pop!
|
115
|
+
rule %r/[^']*/, Literal
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|