rouge 3.10.0 → 3.14.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/demos/apex +9 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/liquid +0 -1
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/nesasm +11 -0
- data/lib/rouge/demos/q +6 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/slice +10 -0
- data/lib/rouge/demos/ttcn3 +6 -0
- data/lib/rouge/guessers/disambiguation.rb +5 -0
- data/lib/rouge/lexer.rb +3 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/bpf.rb +20 -6
- data/lib/rouge/lexers/coq.rb +12 -9
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/d.rb +1 -1
- data/lib/rouge/lexers/dot.rb +2 -2
- data/lib/rouge/lexers/eex.rb +2 -1
- data/lib/rouge/lexers/io.rb +2 -2
- data/lib/rouge/lexers/json.rb +1 -1
- data/lib/rouge/lexers/json_doc.rb +4 -3
- data/lib/rouge/lexers/kotlin.rb +21 -28
- data/lib/rouge/lexers/liquid.rb +82 -108
- data/lib/rouge/lexers/m68k.rb +2 -2
- data/lib/rouge/lexers/magik.rb +1 -1
- data/lib/rouge/lexers/markdown.rb +7 -1
- data/lib/rouge/lexers/mason.rb +0 -5
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/nesasm.rb +78 -0
- data/lib/rouge/lexers/nginx.rb +1 -1
- data/lib/rouge/lexers/perl.rb +1 -1
- data/lib/rouge/lexers/pony.rb +1 -1
- data/lib/rouge/lexers/protobuf.rb +1 -1
- data/lib/rouge/lexers/q.rb +2 -1
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/scala.rb +3 -3
- data/lib/rouge/lexers/shell.rb +5 -3
- data/lib/rouge/lexers/sieve.rb +1 -1
- data/lib/rouge/lexers/slice.rb +32 -0
- data/lib/rouge/lexers/sqf.rb +1 -1
- data/lib/rouge/lexers/swift.rb +1 -1
- data/lib/rouge/lexers/toml.rb +16 -1
- data/lib/rouge/lexers/ttcn3.rb +119 -0
- data/lib/rouge/lexers/verilog.rb +1 -1
- data/lib/rouge/plugins/redcarpet.rb +7 -1
- data/lib/rouge/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d43552856d88e799ffb7f4255d865641bfaafd5dac3945b2646540ff816628c4
|
4
|
+
data.tar.gz: 5768d921766cf2eb677fc63e783b707ee0f52a7320b73f4bbbc333ee14e79f77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdfd25582e56396cb78b370372b4587b243c1608fa7d4ee32a9659f13fc8939bba2305b5add8d83569543766eefed1abbb8ff5f0d76593964db2b3624b1d112b
|
7
|
+
data.tar.gz: 5d2f0526caf091491969d89180fab9a30441ddc5390bbb10c8acb2ea8b9af96b044e91ed32e6db58fa9783a12c530eb3a25d829f031c0ecb7a7e02858592da57
|
data/lib/rouge/demos/liquid
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
% from MiniZinc Handbook:
|
2
|
+
% https://www.minizinc.org/doc-latest/en/modelling.html
|
3
|
+
|
4
|
+
% Colouring Australia using nc colours
|
5
|
+
int: nc = 3;
|
6
|
+
|
7
|
+
var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q;
|
8
|
+
var 1..nc: nsw; var 1..nc: v; var 1..nc: t;
|
9
|
+
|
10
|
+
constraint wa != nt;
|
11
|
+
constraint wa != sa;
|
12
|
+
constraint nt != sa;
|
13
|
+
constraint nt != q;
|
14
|
+
constraint sa != q;
|
15
|
+
constraint sa != nsw;
|
16
|
+
constraint sa != v;
|
17
|
+
constraint q != nsw;
|
18
|
+
constraint nsw != v;
|
19
|
+
solve satisfy;
|
20
|
+
|
21
|
+
output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
|
22
|
+
"q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
|
23
|
+
"t=", show(t), "\n"];
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.bank 0
|
2
|
+
.org $C000
|
3
|
+
Reset:
|
4
|
+
jsr WaitSync ; wait for VSYNC
|
5
|
+
jsr ClearRAM ; clear RAM
|
6
|
+
jsr WaitSync ; wait for VSYNC (and PPU warmup)
|
7
|
+
|
8
|
+
lda #$3f ; $3F -> A register
|
9
|
+
ldy #$00 ; $00 -> Y register
|
10
|
+
sta PPU_ADDR ; write #HIGH byte first
|
11
|
+
sty PPU_ADDR ; $3F00 -> PPU address
|
data/lib/rouge/demos/q
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
*** Settings ***
|
2
|
+
Document Example taken from http://robotframework.org/
|
3
|
+
Suite Setup Open Browser To Login Page
|
4
|
+
Suite Teardown Close Browser
|
5
|
+
Test Setup Go To Login Page
|
6
|
+
Test Template Login With Invalid Credentials Should Fail
|
7
|
+
Resource resource.txt
|
8
|
+
|
9
|
+
*** Test Cases *** User Name Password
|
10
|
+
Invalid Username invalid ${VALID PASSWORD}
|
11
|
+
Invalid Password ${VALID USER} invalid
|
12
|
+
Invalid Username And Password invalid whatever
|
13
|
+
Empty Username ${EMPTY} ${VALID PASSWORD}
|
14
|
+
Empty Password ${VALID USER} ${EMPTY}
|
15
|
+
Empty Username And Password ${EMPTY} ${EMPTY}
|
16
|
+
|
17
|
+
*** Keywords ***
|
18
|
+
Login With Invalid Credentials Should Fail
|
19
|
+
[Arguments] ${username} ${password}
|
20
|
+
Input Username ${username}
|
21
|
+
Input Password ${password}
|
22
|
+
Submit Credentials
|
23
|
+
Login Should Have Failed
|
24
|
+
|
25
|
+
Login Should Have Failed
|
26
|
+
Location Should Be ${ERROR URL}
|
27
|
+
Title Should Be Error Page
|
data/lib/rouge/lexer.rb
CHANGED
@@ -49,6 +49,9 @@ module Rouge
|
|
49
49
|
#
|
50
50
|
# Lexer.find_fancy('guess', "#!/bin/bash\necho Hello, world")
|
51
51
|
#
|
52
|
+
# If the code matches more than one lexer then Guesser::Ambiguous
|
53
|
+
# is raised.
|
54
|
+
#
|
52
55
|
# This is used in the Redcarpet plugin as well as Rouge's own
|
53
56
|
# markdown lexer for highlighting internal code blocks.
|
54
57
|
#
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class Apex < RegexLexer
|
7
|
+
title "Apex"
|
8
|
+
desc "The Apex programming language (provided by salesforce)"
|
9
|
+
|
10
|
+
tag 'apex'
|
11
|
+
filenames '*.cls'
|
12
|
+
mimetypes 'text/x-apex'
|
13
|
+
|
14
|
+
def self.keywords
|
15
|
+
@keywords ||= Set.new %w(
|
16
|
+
assert break case catch continue default do else finally for if goto
|
17
|
+
instanceof new return switch this throw try while insert update
|
18
|
+
delete
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.declarations
|
23
|
+
@declarations ||= Set.new %w(
|
24
|
+
abstract const enum extends final implements native private protected
|
25
|
+
public static super synchronized throws transient volatile with
|
26
|
+
sharing without inherited virtual global testmethod
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.soql
|
31
|
+
@soql ||= Set.new %w(
|
32
|
+
SELECT FROM WHERE UPDATE LIKE TYPEOF END USING SCOPE WITH DATA
|
33
|
+
CATEGORY GROUP BY ROLLUP CUBE HAVING ORDER BY ASC DESC NULLS FIRST
|
34
|
+
LAST LIMIT OFFSET FOR VIEW REFERENCE UPDATE TRACKING VIEWSTAT OR AND
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.types
|
39
|
+
@types ||= Set.new %w(
|
40
|
+
String boolean byte char double float int long short var void
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.constants
|
45
|
+
@constants ||= Set.new %w(true false null)
|
46
|
+
end
|
47
|
+
|
48
|
+
id = /[a-z_][a-z0-9_]*/i
|
49
|
+
|
50
|
+
state :root do
|
51
|
+
rule %r/\s+/m, Text
|
52
|
+
|
53
|
+
rule %r(//.*?$), Comment::Single
|
54
|
+
rule %r(/\*.*?\*/)m, Comment::Multiline
|
55
|
+
|
56
|
+
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
57
|
+
rule %r/import\b/, Keyword::Namespace, :import
|
58
|
+
|
59
|
+
rule %r/([@$.]?)(#{id})([:(]?)/io do |m|
|
60
|
+
if self.class.keywords.include? m[0].downcase
|
61
|
+
token Keyword
|
62
|
+
elsif self.class.soql.include? m[0].upcase
|
63
|
+
token Keyword
|
64
|
+
elsif self.class.declarations.include? m[0].downcase
|
65
|
+
token Keyword::Declaration
|
66
|
+
elsif self.class.types.include? m[0].downcase
|
67
|
+
token Keyword::Type
|
68
|
+
elsif self.class.constants.include? m[0].downcase
|
69
|
+
token Keyword::Constant
|
70
|
+
elsif 'package'.casecmp m[0]
|
71
|
+
token Keyword::Namespace
|
72
|
+
elsif m[1] == "@"
|
73
|
+
token Name::Decorator
|
74
|
+
elsif m[3] == ":"
|
75
|
+
groups Operator, Name::Label, Punctuation
|
76
|
+
elsif m[3] == "("
|
77
|
+
groups Operator, Name::Function, Punctuation
|
78
|
+
elsif m[1] == "."
|
79
|
+
groups Operator, Name::Property, Punctuation
|
80
|
+
else
|
81
|
+
token Name
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
rule %r/"/, Str::Double, :dq
|
86
|
+
rule %r/'/, Str::Single, :sq
|
87
|
+
|
88
|
+
digit = /[0-9]_+[0-9]|[0-9]/
|
89
|
+
rule %r/#{digit}+\.#{digit}+([eE]#{digit}+)?[fd]?/, Num::Float
|
90
|
+
rule %r/0b(?:[01]_+[01]|[01])+/i, Num::Bin
|
91
|
+
rule %r/0x(?:\h_+\h|\h)+/i, Num::Hex
|
92
|
+
rule %r/0(?:[0-7]_+[0-7]|[0-7])+/, Num::Oct
|
93
|
+
rule %r/#{digit}+L?/, Num::Integer
|
94
|
+
|
95
|
+
rule %r/[-+\/*~^!%&<>|=.?]/, Operator
|
96
|
+
rule %r/[\[\](){},:;]/, Punctuation;
|
97
|
+
end
|
98
|
+
|
99
|
+
state :class do
|
100
|
+
rule %r/\s+/m, Text
|
101
|
+
rule id, Name::Class, :pop!
|
102
|
+
end
|
103
|
+
|
104
|
+
state :import do
|
105
|
+
rule %r/\s+/m, Text
|
106
|
+
rule %r/[a-z0-9_.]+\*?/i, Name::Namespace, :pop!
|
107
|
+
end
|
108
|
+
|
109
|
+
state :escape do
|
110
|
+
rule %r/\\[btnfr\\"']/, Str::Escape
|
111
|
+
end
|
112
|
+
|
113
|
+
state :dq do
|
114
|
+
mixin :escape
|
115
|
+
rule %r/[^\\"]+/, Str::Double
|
116
|
+
rule %r/"/, Str::Double, :pop!
|
117
|
+
end
|
118
|
+
|
119
|
+
state :sq do
|
120
|
+
mixin :escape
|
121
|
+
rule %r/[^\\']+/, Str::Double
|
122
|
+
rule %r/'/, Str::Double, :pop!
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
data/lib/rouge/lexers/bpf.rb
CHANGED
@@ -13,14 +13,28 @@ module Rouge
|
|
13
13
|
).join('|')
|
14
14
|
|
15
15
|
MISC_KEYWORDS = %w(
|
16
|
-
be16 be32 be64 exit lock
|
16
|
+
be16 be32 be64 exit lock map
|
17
17
|
).join('|')
|
18
18
|
|
19
19
|
state :root do
|
20
|
+
# Line numbers and hexadecimal output from bpftool/objdump
|
21
|
+
rule %r/(\d+)(:)(\s+)(\(\h{2}\))/i do
|
22
|
+
groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
|
23
|
+
end
|
24
|
+
rule %r/(\d+)(:)(\s+)((?:\h{2} ){8})/i do
|
25
|
+
groups Generic::Lineno, Punctuation, Text::Whitespace, Generic
|
26
|
+
end
|
27
|
+
rule %r/(\d+)(:)(\s+)/i do
|
28
|
+
groups Generic::Lineno, Punctuation, Text::Whitespace
|
29
|
+
end
|
30
|
+
|
20
31
|
# Calls to helpers
|
21
32
|
rule %r/(call)(\s+)(\d+)/i do
|
22
33
|
groups Keyword, Text::Whitespace, Literal::Number::Integer
|
23
34
|
end
|
35
|
+
rule %r/(call)(\s+)(\w+)(#)(\d+)/i do
|
36
|
+
groups Keyword, Text::Whitespace, Name::Builtin, Punctuation, Literal::Number::Integer
|
37
|
+
end
|
24
38
|
|
25
39
|
# Unconditional jumps
|
26
40
|
rule %r/(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
|
@@ -28,10 +42,10 @@ module Rouge
|
|
28
42
|
end
|
29
43
|
|
30
44
|
# Conditional jumps
|
31
|
-
rule %r/(if)(\s+)(
|
45
|
+
rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)(0x\h+|[-]?\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
|
32
46
|
groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
|
33
47
|
end
|
34
|
-
rule %r/(if)(\s+)(
|
48
|
+
rule %r/(if)(\s+)([rw]\d+)(\s*)([s!=<>]+)(\s*)([rw]\d+)(\s*)(goto)(\s*)(\+\d+)?(\s*)(<?\w+>?)/i do
|
35
49
|
groups Keyword, Text::Whitespace, Name, Text::Whitespace, Operator, Text::Whitespace, Name, Text::Whitespace, Keyword, Text::Whitespace, Literal::Number::Integer, Text::Whitespace, Name::Label
|
36
50
|
end
|
37
51
|
|
@@ -45,7 +59,7 @@ module Rouge
|
|
45
59
|
rule %r/[+-\/\*&|><^s]{0,3}=/i, Operator
|
46
60
|
|
47
61
|
# Registers
|
48
|
-
rule %r/([+-]?)(
|
62
|
+
rule %r/([+-]?)([rw]\d+)/i do
|
49
63
|
groups Punctuation, Name
|
50
64
|
end
|
51
65
|
|
@@ -73,7 +87,7 @@ module Rouge
|
|
73
87
|
|
74
88
|
state :address do
|
75
89
|
# Address is offset from register
|
76
|
-
rule %r/(\()(
|
90
|
+
rule %r/(\()([rw]\d+)(\s*)([+-])(\s*)(\d+)(\))/i do
|
77
91
|
groups Punctuation, Name, Text::Whitespace, Operator, Text::Whitespace, Literal::Number::Integer, Punctuation
|
78
92
|
pop!
|
79
93
|
end
|
@@ -83,7 +97,7 @@ module Rouge
|
|
83
97
|
groups Name, Punctuation, Literal::Number::Integer, Punctuation
|
84
98
|
pop!
|
85
99
|
end
|
86
|
-
rule %r/(\w+)(\[)(
|
100
|
+
rule %r/(\w+)(\[)([rw]\d+)(\])/i do
|
87
101
|
groups Name, Punctuation, Name, Punctuation
|
88
102
|
pop!
|
89
103
|
end
|
data/lib/rouge/lexers/coq.rb
CHANGED
@@ -58,7 +58,7 @@ module Rouge
|
|
58
58
|
|
59
59
|
def self.keyopts
|
60
60
|
@keyopts ||= Set.new %w(
|
61
|
-
:= => -> /\\ \\/ _ ; :> :
|
61
|
+
:= => -> /\\ \\/ _ ; :> : ⇒ → ↔ ⇔ ≔ ≡ ∀ ∃ ∧ ∨ ¬ ⊤ ⊥ ⊢ ⊨ ∈
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
@@ -115,14 +115,6 @@ module Rouge
|
|
115
115
|
end
|
116
116
|
rule %r(/\\), Operator
|
117
117
|
rule %r/\\\//, Operator
|
118
|
-
rule operator do |m|
|
119
|
-
match = m[0]
|
120
|
-
if self.class.keyopts.include? match
|
121
|
-
token Punctuation
|
122
|
-
else
|
123
|
-
token Operator
|
124
|
-
end
|
125
|
-
end
|
126
118
|
|
127
119
|
rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
|
128
120
|
rule %r/\d[\d_]*/, Num::Integer
|
@@ -131,6 +123,17 @@ module Rouge
|
|
131
123
|
rule %r/'/, Keyword
|
132
124
|
rule %r/"/, Str::Double, :string
|
133
125
|
rule %r/[~?]#{id}/, Name::Variable
|
126
|
+
|
127
|
+
rule %r/./ do |m|
|
128
|
+
match = m[0]
|
129
|
+
if self.class.keyopts.include? match
|
130
|
+
token Punctuation
|
131
|
+
elsif match =~ operator
|
132
|
+
token Operator
|
133
|
+
else
|
134
|
+
token Error
|
135
|
+
end
|
136
|
+
end
|
134
137
|
end
|
135
138
|
|
136
139
|
state :comment do
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Rouge
|
5
|
+
module Lexers
|
6
|
+
class CSVS < RegexLexer
|
7
|
+
tag 'csvs'
|
8
|
+
title "csvs"
|
9
|
+
desc 'The CSV Schema Language (digital-preservation.github.io)'
|
10
|
+
filenames '*.csvs'
|
11
|
+
|
12
|
+
state :root do
|
13
|
+
rule %r/\s+/m, Text
|
14
|
+
|
15
|
+
rule %r(//[\S\t ]*), Comment::Single
|
16
|
+
rule %r(/\*[^*]*\*/)m, Comment::Multiline
|
17
|
+
|
18
|
+
rule %r/(version)( )(\d+\.\d+)/ do
|
19
|
+
groups Keyword, Text::Whitespace, Num::Float
|
20
|
+
end
|
21
|
+
|
22
|
+
rule %r/T?\d{2}:\d{2}:\d{2}(\.\d{5})?(Z|(?:[-+]\d{2}:\d{2}))?/, Literal::Date
|
23
|
+
rule %r/\d{4}-\d{2}-\d{2}/, Literal::Date
|
24
|
+
rule %r/\d{2}\/\d{2}\/\d{4}/, Literal::Date
|
25
|
+
|
26
|
+
rule %r((\d+[.]?\d*|\d*[.]\d+)(e[+-]?[0-9]+)?)i, Num::Float
|
27
|
+
rule %r/\d+/, Num::Integer
|
28
|
+
|
29
|
+
rule %r/@\w+/, Keyword::Pseudo
|
30
|
+
|
31
|
+
rule %r/[-.\w]+:/, Name::Variable
|
32
|
+
rule %r/^"[^"]+"/, Name::Variable
|
33
|
+
rule %r/\$([-.\w]+|("[^"]+"))\/?/, Name::Variable
|
34
|
+
|
35
|
+
rule %r/[A-Z]+/i, Keyword
|
36
|
+
|
37
|
+
rule %r/"[^"]*"/, Str::Double
|
38
|
+
rule %r/'[^\r\n\f']'/, Str::Char
|
39
|
+
|
40
|
+
rule %r/[,()*]/, Punctuation
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/rouge/lexers/d.rb
CHANGED
@@ -48,7 +48,7 @@ module Rouge
|
|
48
48
|
state :root do
|
49
49
|
mixin :whitespace
|
50
50
|
# Comments
|
51
|
-
rule %r(
|
51
|
+
rule %r(//.*), Comment::Single
|
52
52
|
rule %r(/(\\\n)?[*](.|\n)*?[*](\\\n)?/), Comment::Multiline
|
53
53
|
rule %r(/\+), Comment::Multiline, :nested_comment
|
54
54
|
# Keywords
|