rouge 4.1.3 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -7
- data/LICENSE +2 -1
- data/lib/rouge/cli.rb +4 -5
- data/lib/rouge/demos/bicep +10 -0
- data/lib/rouge/demos/cobol +103 -0
- data/lib/rouge/demos/codeowners +6 -0
- data/lib/rouge/demos/gjs +23 -0
- data/lib/rouge/demos/gts +36 -0
- data/lib/rouge/demos/iecst +21 -0
- data/lib/rouge/demos/json5 +12 -0
- data/lib/rouge/demos/mojo +10 -0
- data/lib/rouge/demos/p4 +99 -0
- data/lib/rouge/demos/svelte +29 -0
- data/lib/rouge/formatters/html_legacy.rb +0 -3
- data/lib/rouge/guessers/disambiguation.rb +24 -3
- data/lib/rouge/lexer.rb +8 -6
- data/lib/rouge/lexers/ada.rb +5 -5
- data/lib/rouge/lexers/bicep.rb +111 -0
- data/lib/rouge/lexers/bpf.rb +10 -10
- data/lib/rouge/lexers/brainfuck.rb +1 -0
- data/lib/rouge/lexers/clean.rb +4 -4
- data/lib/rouge/lexers/cobol.rb +137 -0
- data/lib/rouge/lexers/codeowners.rb +30 -0
- data/lib/rouge/lexers/cpp.rb +5 -4
- data/lib/rouge/lexers/crystal.rb +17 -17
- data/lib/rouge/lexers/csharp.rb +37 -34
- data/lib/rouge/lexers/css.rb +192 -150
- data/lib/rouge/lexers/dart.rb +1 -1
- data/lib/rouge/lexers/docker.rb +2 -2
- data/lib/rouge/lexers/ecl.rb +2 -2
- data/lib/rouge/lexers/eiffel.rb +1 -1
- data/lib/rouge/lexers/elixir.rb +5 -1
- data/lib/rouge/lexers/gdscript.rb +4 -4
- data/lib/rouge/lexers/ghc_cmm.rb +3 -3
- data/lib/rouge/lexers/gjs.rb +39 -0
- data/lib/rouge/lexers/go.rb +7 -5
- data/lib/rouge/lexers/groovy.rb +6 -4
- data/lib/rouge/lexers/gts.rb +39 -0
- data/lib/rouge/lexers/hcl.rb +1 -0
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/iecst.rb +92 -0
- data/lib/rouge/lexers/ini.rb +7 -5
- data/lib/rouge/lexers/java.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +4 -4
- data/lib/rouge/lexers/json5.rb +74 -0
- data/lib/rouge/lexers/julia.rb +3 -2
- data/lib/rouge/lexers/kotlin.rb +1 -1
- data/lib/rouge/lexers/lua.rb +24 -3
- data/lib/rouge/lexers/make.rb +5 -1
- data/lib/rouge/lexers/markdown.rb +2 -1
- data/lib/rouge/lexers/mathematica.rb +1 -1
- data/lib/rouge/lexers/meson.rb +0 -1
- data/lib/rouge/lexers/mojo.rb +35 -0
- data/lib/rouge/lexers/nasm.rb +5 -4
- data/lib/rouge/lexers/nginx.rb +1 -0
- data/lib/rouge/lexers/objective_c/common.rb +0 -2
- data/lib/rouge/lexers/objective_c.rb +1 -1
- data/lib/rouge/lexers/ocl.rb +2 -2
- data/lib/rouge/lexers/openedge.rb +0 -2
- data/lib/rouge/lexers/p4.rb +81 -0
- data/lib/rouge/lexers/php/keywords.rb +86 -136
- data/lib/rouge/lexers/php.rb +42 -2
- data/lib/rouge/lexers/plsql.rb +5 -5
- data/lib/rouge/lexers/python.rb +59 -32
- data/lib/rouge/lexers/robot_framework.rb +1 -1
- data/lib/rouge/lexers/ruby.rb +21 -21
- data/lib/rouge/lexers/sass/common.rb +1 -1
- data/lib/rouge/lexers/scala.rb +5 -2
- data/lib/rouge/lexers/sql.rb +1 -1
- data/lib/rouge/lexers/svelte.rb +91 -0
- data/lib/rouge/lexers/syzlang.rb +0 -1
- data/lib/rouge/lexers/tcl.rb +7 -2
- data/lib/rouge/lexers/terraform.rb +4 -3
- data/lib/rouge/lexers/toml.rb +56 -45
- data/lib/rouge/lexers/ttcn3.rb +0 -2
- data/lib/rouge/lexers/typescript/common.rb +9 -0
- data/lib/rouge/lexers/xojo.rb +6 -6
- data/lib/rouge/lexers/yang.rb +1 -1
- data/lib/rouge/regex_lexer.rb +13 -0
- data/lib/rouge/tex_theme_renderer.rb +1 -1
- data/lib/rouge/themes/base16.rb +23 -18
- data/lib/rouge/themes/bw.rb +1 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +4 -1
- data/lib/rouge/themes/igor_pro.rb +3 -0
- data/lib/rouge/themes/magritte.rb +1 -0
- data/lib/rouge/themes/molokai.rb +2 -1
- data/lib/rouge/themes/monokai.rb +2 -1
- data/lib/rouge/themes/monokai_sublime.rb +4 -3
- data/lib/rouge/themes/pastie.rb +1 -0
- data/lib/rouge/themes/thankful_eyes.rb +1 -0
- data/lib/rouge/themes/tulip.rb +1 -0
- data/lib/rouge/token.rb +2 -1
- data/lib/rouge/version.rb +1 -1
- metadata +23 -6
data/lib/rouge/lexers/groovy.rb
CHANGED
|
@@ -7,11 +7,13 @@ module Rouge
|
|
|
7
7
|
title "Groovy"
|
|
8
8
|
desc 'The Groovy programming language (http://www.groovy-lang.org/)'
|
|
9
9
|
tag 'groovy'
|
|
10
|
-
|
|
10
|
+
aliases 'nextflow', 'nf'
|
|
11
|
+
filenames '*.groovy', 'Jenkinsfile', '*.Jenkinsfile', '*.nf'
|
|
11
12
|
mimetypes 'text/x-groovy'
|
|
12
13
|
|
|
13
14
|
def self.detect?(text)
|
|
14
15
|
return true if text.shebang?(/groovy/)
|
|
16
|
+
return true if text.shebang?(/nextflow/)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def self.keywords
|
|
@@ -23,7 +25,7 @@ module Rouge
|
|
|
23
25
|
|
|
24
26
|
def self.declarations
|
|
25
27
|
@declarations ||= Set.new %w(
|
|
26
|
-
abstract const
|
|
28
|
+
abstract const extends final implements native private
|
|
27
29
|
protected public static strictfp super synchronized throws
|
|
28
30
|
transient volatile
|
|
29
31
|
)
|
|
@@ -31,7 +33,7 @@ module Rouge
|
|
|
31
33
|
|
|
32
34
|
def self.types
|
|
33
35
|
@types ||= Set.new %w(
|
|
34
|
-
def boolean byte char double float int long short void
|
|
36
|
+
def var boolean byte char double float int long short void
|
|
35
37
|
)
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -56,7 +58,7 @@ module Rouge
|
|
|
56
58
|
rule %r(//.*?$), Comment::Single
|
|
57
59
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
|
58
60
|
rule %r/@\w[\w.]*/, Name::Decorator
|
|
59
|
-
rule %r/(class|interface|trait)\b/, Keyword::Declaration, :class
|
|
61
|
+
rule %r/(class|interface|trait|enum|record)\b/, Keyword::Declaration, :class
|
|
60
62
|
rule %r/package\b/, Keyword::Namespace, :import
|
|
61
63
|
rule %r/import\b/, Keyword::Namespace, :import
|
|
62
64
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
load_lexer 'typescript.rb'
|
|
7
|
+
|
|
8
|
+
class Gts < Typescript
|
|
9
|
+
title "Template Tag (gts)"
|
|
10
|
+
desc "Ember.js, TypeScript with <template> tags"
|
|
11
|
+
tag "gts"
|
|
12
|
+
filenames "*.gts"
|
|
13
|
+
mimetypes "text/x-gts", "application/x-gts"
|
|
14
|
+
|
|
15
|
+
def initialize(*)
|
|
16
|
+
super
|
|
17
|
+
@handlebars = Handlebars.new(options)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
prepend :root do
|
|
21
|
+
rule %r/(<)(template)(>)/ do
|
|
22
|
+
groups Name::Tag, Keyword, Name::Tag
|
|
23
|
+
push :template
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
state :template do
|
|
28
|
+
rule %r((</)(template)(>)) do
|
|
29
|
+
groups Name::Tag, Keyword, Name::Tag
|
|
30
|
+
pop!
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
rule %r/.+?(?=<\/template>)/m do
|
|
34
|
+
delegate @handlebars
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
data/lib/rouge/lexers/hcl.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Rouge
|
|
|
26
26
|
state :primitives do
|
|
27
27
|
rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?([kKmMgG]b?)?/, Num::Float
|
|
28
28
|
rule %r/[0-9]+([kKmMgG]b?)?/, Num::Integer
|
|
29
|
+
rule %r/[-+*\/!%&<>|=:?]/, Operator
|
|
29
30
|
|
|
30
31
|
rule %r/"/, Str::Double, :dq
|
|
31
32
|
rule %r/'/, Str::Single, :sq
|
data/lib/rouge/lexers/html.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Rouge
|
|
|
7
7
|
title "HTML"
|
|
8
8
|
desc "HTML, the markup language of the web"
|
|
9
9
|
tag 'html'
|
|
10
|
-
filenames '*.htm', '*.html', '*.xhtml', '*.cshtml'
|
|
10
|
+
filenames '*.htm', '*.html', '*.xhtml', '*.cshtml', '*.razor'
|
|
11
11
|
mimetypes 'text/html', 'application/xhtml+xml'
|
|
12
12
|
|
|
13
13
|
def self.detect?(text)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
class IecST < RegexLexer
|
|
7
|
+
tag 'iecst'
|
|
8
|
+
title "IEC 61131-3 Structured Text"
|
|
9
|
+
desc 'Structured text is a programming language for PLCs (programmable logic controllers).'
|
|
10
|
+
filenames '*.awl', '*.scl', '*.st'
|
|
11
|
+
|
|
12
|
+
mimetypes 'text/x-iecst'
|
|
13
|
+
|
|
14
|
+
def self.keywords
|
|
15
|
+
blocks = %w(
|
|
16
|
+
PROGRAM CONFIGURATION INITIAL_STEP INTERFACE FUNCTION_BLOCK FUNCTION ACTION TRANSITION
|
|
17
|
+
TYPE STRUCT STEP NAMESPACE LIBRARY CHANNEL FOLDER RESOURCE
|
|
18
|
+
VAR_ACCESS VAR_CONFIG VAR_EXTERNAL VAR_GLOBAL VAR_INPUT VAR_IN_OUT VAR_OUTPUT VAR_TEMP VAR
|
|
19
|
+
CONST METHOD PROPERTY
|
|
20
|
+
CASE FOR IF REPEAT WHILE
|
|
21
|
+
)
|
|
22
|
+
@keywords ||= Set.new %w(
|
|
23
|
+
AT BEGIN BY CONSTANT CONTINUE DO ELSE ELSIF EXIT EXTENDS FROM GET GOTO IMPLEMENTS JMP
|
|
24
|
+
NON_RETAIN OF PRIVATE PROTECTED PUBLIC RETAIN RETURN SET TASK THEN TO UNTIL USING WITH
|
|
25
|
+
__CATCH __ENDTRY __FINALLY __TRY
|
|
26
|
+
) + blocks + blocks.map {|kw| "END_" + kw}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.types
|
|
30
|
+
@types ||= Set.new %w(
|
|
31
|
+
ANY ARRAY BOOL BYTE POINTER STRING
|
|
32
|
+
DATE DATE_AND_TIME DT TIME TIME_OF_DAY TOD
|
|
33
|
+
INT DINT LINT SINT UINT UDINT ULINT USINT
|
|
34
|
+
WORD DWORD LWORD
|
|
35
|
+
REAL LREAL
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.literals
|
|
40
|
+
@literals ||= Set.new %w(TRUE FALSE NULL)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.operators
|
|
44
|
+
@operators ||= Set.new %w(AND EQ EXPT GE GT LE LT MOD NE NOT OR XOR)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
state :whitespace do
|
|
48
|
+
# Spaces
|
|
49
|
+
rule %r/\s+/m, Text
|
|
50
|
+
# // Comments
|
|
51
|
+
rule %r((//).*$\n?), Comment::Single
|
|
52
|
+
# (* Comments *)
|
|
53
|
+
rule %r(\(\*.*?\*\))m, Comment::Multiline
|
|
54
|
+
# { Comments }
|
|
55
|
+
rule %r(\{.*?\})m, Comment::Special
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
state :root do
|
|
59
|
+
mixin :whitespace
|
|
60
|
+
|
|
61
|
+
rule %r/'[^']+'/, Literal::String::Single
|
|
62
|
+
rule %r/"[^"]+"/, Literal::String::Symbol
|
|
63
|
+
rule %r/%[IQM][XBWDL][\d.]*|%[IQ][\d.]*/, Name::Variable::Magic
|
|
64
|
+
rule %r/\b(?:D|DT|T|TOD)#[\d_shmd:]*/i, Literal::Date
|
|
65
|
+
rule %r/\b(?:16#[\d_a-f]+|0x[\d_a-f]+)\b/i, Literal::Number::Hex
|
|
66
|
+
rule %r/\b2#[01_]+/, Literal::Number::Bin
|
|
67
|
+
rule %r/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, Literal::Number::Float
|
|
68
|
+
rule %r/\b[\d.,_]+/, Literal::Number
|
|
69
|
+
|
|
70
|
+
rule %r/\b[A-Z_]+\b/i do |m|
|
|
71
|
+
name = m[0].upcase
|
|
72
|
+
if self.class.keywords.include?(name)
|
|
73
|
+
token Keyword
|
|
74
|
+
elsif self.class.types.include?(name)
|
|
75
|
+
token Keyword::Type
|
|
76
|
+
elsif self.class.literals.include?(name)
|
|
77
|
+
token Literal
|
|
78
|
+
elsif self.class.operators.include?(name)
|
|
79
|
+
token Operator
|
|
80
|
+
else
|
|
81
|
+
token Name
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
rule %r/S?R?:?=>?|&&?|\*\*?|<[=>]?|>=?|[-:^\/+#]/, Operator
|
|
86
|
+
rule %r/\b[a-z_]\w*(?=\s*\()/i, Name::Function
|
|
87
|
+
rule %r/\b[a-z_]\w*\b/i, Name
|
|
88
|
+
rule %r/[()\[\].,;]/, Punctuation
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
data/lib/rouge/lexers/ini.rb
CHANGED
|
@@ -8,15 +8,14 @@ module Rouge
|
|
|
8
8
|
desc 'the INI configuration format'
|
|
9
9
|
tag 'ini'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mimetypes 'text/x-ini'
|
|
11
|
+
filenames '*.ini', '*.INI', '*.gitconfig', '*.cfg', '.editorconfig', '*.inf'
|
|
12
|
+
mimetypes 'text/x-ini', 'text/inf'
|
|
14
13
|
|
|
15
14
|
identifier = /[\w\-.]+/
|
|
16
15
|
|
|
17
16
|
state :basic do
|
|
17
|
+
rule %r/\s+/, Text::Whitespace
|
|
18
18
|
rule %r/[;#].*?\n/, Comment
|
|
19
|
-
rule %r/\s+/, Text
|
|
20
19
|
rule %r/\\\n/, Str::Escape
|
|
21
20
|
end
|
|
22
21
|
|
|
@@ -24,11 +23,14 @@ module Rouge
|
|
|
24
23
|
mixin :basic
|
|
25
24
|
|
|
26
25
|
rule %r/(#{identifier})(\s*)(=)/ do
|
|
27
|
-
groups Name::Property, Text, Punctuation
|
|
26
|
+
groups Name::Property, Text::Whitespace, Punctuation
|
|
28
27
|
push :value
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
rule %r/\[.*?\]/, Name::Namespace
|
|
31
|
+
|
|
32
|
+
# standalone option, supported by some INI parsers
|
|
33
|
+
rule %r/(.+?)/, Name::Attribute
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
state :value do
|
data/lib/rouge/lexers/java.rb
CHANGED
|
@@ -51,7 +51,7 @@ module Rouge
|
|
|
51
51
|
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
|
52
52
|
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
|
|
53
53
|
rule %r/(?:true|false|null)\b/, Keyword::Constant
|
|
54
|
-
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
|
54
|
+
rule %r/(?:class|interface|record)\b/, Keyword::Declaration, :class
|
|
55
55
|
rule %r/(?:import|package)\b/, Keyword::Namespace, :import
|
|
56
56
|
rule %r/"""\s*\n.*?(?<!\\)"""/m, Str::Heredoc
|
|
57
57
|
rule %r/"(\\\\|\\"|[^"])*"/, Str
|
|
@@ -100,7 +100,7 @@ module Rouge
|
|
|
100
100
|
|
|
101
101
|
def self.keywords
|
|
102
102
|
@keywords ||= Set.new %w(
|
|
103
|
-
|
|
103
|
+
async await break case catch continue debugger default delete
|
|
104
104
|
do else export finally from for if import in instanceof new of
|
|
105
105
|
return super switch this throw try typeof void while yield
|
|
106
106
|
)
|
|
@@ -190,8 +190,8 @@ module Rouge
|
|
|
190
190
|
|
|
191
191
|
rule %r/function(?=(\(.*\)))/, Keyword::Declaration # For anonymous functions
|
|
192
192
|
|
|
193
|
-
rule %r/(
|
|
194
|
-
if self.class.keywords.include?
|
|
193
|
+
rule %r/(#?#{id})[ \t]*(?=(\(.*\)))/m do |m|
|
|
194
|
+
if self.class.keywords.include?(m[1])
|
|
195
195
|
# "if" in "if (...)" or "switch" in "switch (...)" are recognized as keywords.
|
|
196
196
|
token Keyword
|
|
197
197
|
else
|
|
@@ -201,7 +201,7 @@ module Rouge
|
|
|
201
201
|
|
|
202
202
|
rule %r/[{}]/, Punctuation, :statement
|
|
203
203
|
|
|
204
|
-
rule id do |m|
|
|
204
|
+
rule %r/#?#{id}/ do |m|
|
|
205
205
|
if self.class.keywords.include? m[0]
|
|
206
206
|
token Keyword
|
|
207
207
|
push :expr_start
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
load_lexer 'json.rb'
|
|
7
|
+
|
|
8
|
+
class JSON5 < JSON
|
|
9
|
+
title 'JSON 5'
|
|
10
|
+
tag 'json5'
|
|
11
|
+
filenames '*.json5'
|
|
12
|
+
mimetypes 'application/json5', 'application/x-json5'
|
|
13
|
+
|
|
14
|
+
desc 'JSON 5 extension for JSON (json5.org)'
|
|
15
|
+
|
|
16
|
+
append :whitespace do
|
|
17
|
+
rule %r://.*$:, Comment
|
|
18
|
+
|
|
19
|
+
# comments are non-nesting, so a single regex will do
|
|
20
|
+
rule %r:/[*].*?[*]/:m, Comment
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
prepend :name do
|
|
24
|
+
rule Javascript.id_regex, Name::Label
|
|
25
|
+
rule %r/".*?"/, Name::Label
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# comments can appear between keys and :, so we have to
|
|
29
|
+
# manage our states a little more carefully
|
|
30
|
+
append :object do
|
|
31
|
+
rule %r/:/ do
|
|
32
|
+
token Punctuation
|
|
33
|
+
goto :object_value
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
state :object_value do
|
|
38
|
+
mixin :value
|
|
39
|
+
rule %r/,/ do
|
|
40
|
+
token Punctuation
|
|
41
|
+
goto :object
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
rule %r/}/, Punctuation, :pop!
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
append :value do
|
|
48
|
+
rule %r/'/, Str::Single, :sstring
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
state :sstring do
|
|
52
|
+
rule %r/[^\\']+/, Str::Single
|
|
53
|
+
rule %r/\\./m, Str::Escape
|
|
54
|
+
rule %r/'/, Str::Single, :pop!
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# can escape newlines
|
|
58
|
+
append :string do
|
|
59
|
+
rule %r/\\./m, Str::Escape
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# override: numbers are very different in json5
|
|
63
|
+
state :constants do
|
|
64
|
+
rule %r/\b(?:true|false|null)\b/, Keyword::Constant
|
|
65
|
+
rule %r/[+-]?\b(?:Infinity|NaN)\b/, Keyword::Constant
|
|
66
|
+
rule %r/[+-]?0x\h+/i, Num::Hex
|
|
67
|
+
|
|
68
|
+
rule %r/[+-.]?[0-9]+[.]?[0-9]?([eE][-]?[0-9]+)?/i, Num::Float
|
|
69
|
+
rule %r/[+-]?\d+e[+-]?\d+/, Num::Integer
|
|
70
|
+
rule %r/[+-]?(?:0|[1-9]\d*)(?:e[+-]?\d+)?/i, Num::Integer
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/rouge/lexers/julia.rb
CHANGED
|
@@ -252,15 +252,16 @@ module Rouge
|
|
|
252
252
|
rule %r/\d+/, Literal::Number::Integer
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
+
NAME_RE = %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/
|
|
255
256
|
|
|
256
257
|
state :funcname do
|
|
257
|
-
rule
|
|
258
|
+
rule NAME_RE, Name::Function, :pop!
|
|
258
259
|
rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop!
|
|
259
260
|
rule %r/[^\s\w{]{1,2}/, Operator, :pop!
|
|
260
261
|
end
|
|
261
262
|
|
|
262
263
|
state :typename do
|
|
263
|
-
rule
|
|
264
|
+
rule NAME_RE, Name::Class, :pop!
|
|
264
265
|
end
|
|
265
266
|
|
|
266
267
|
state :stringescape do
|
data/lib/rouge/lexers/kotlin.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Rouge
|
|
|
24
24
|
while yield
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
-
name_chars = %r'[
|
|
27
|
+
name_chars = %r'[-\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
|
|
28
28
|
|
|
29
29
|
class_name = %r'`?[\p{Lu}]#{name_chars}`?'
|
|
30
30
|
name = %r'`?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}]#{name_chars}`?'
|
data/lib/rouge/lexers/lua.rb
CHANGED
|
@@ -105,7 +105,26 @@ module Rouge
|
|
|
105
105
|
rule %r/\)/, Punctuation, :pop!
|
|
106
106
|
rule %r/[(,]/, Punctuation
|
|
107
107
|
rule %r/\s+/, Text
|
|
108
|
-
rule %r/
|
|
108
|
+
rule %r/'/, Str::Regex, :regex_sq
|
|
109
|
+
rule %r/"/, Str::Regex, :regex_dq
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
state :regex_sq do
|
|
113
|
+
rule %r(') do
|
|
114
|
+
token Str::Regex
|
|
115
|
+
goto :regex_end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
mixin :regex
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
state :regex_dq do
|
|
122
|
+
rule %r(") do
|
|
123
|
+
token Str::Regex
|
|
124
|
+
goto :regex_end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
mixin :regex
|
|
109
128
|
end
|
|
110
129
|
|
|
111
130
|
state :regex do
|
|
@@ -151,13 +170,15 @@ module Rouge
|
|
|
151
170
|
end
|
|
152
171
|
|
|
153
172
|
state :sqs do
|
|
173
|
+
rule %r(\\'), Str::Escape
|
|
154
174
|
rule %r('), Str::Single, :pop!
|
|
155
|
-
rule %r([^']+), Str::Single
|
|
175
|
+
rule %r([^'\\]+), Str::Single
|
|
156
176
|
end
|
|
157
177
|
|
|
158
178
|
state :dqs do
|
|
179
|
+
rule %r(\\"), Str::Escape
|
|
159
180
|
rule %r("), Str::Double, :pop!
|
|
160
|
-
rule %r([^"]+), Str::Double
|
|
181
|
+
rule %r([^"\\]+), Str::Double
|
|
161
182
|
end
|
|
162
183
|
end
|
|
163
184
|
end
|
data/lib/rouge/lexers/make.rb
CHANGED
|
@@ -40,6 +40,10 @@ module Rouge
|
|
|
40
40
|
groups Keyword, Text, Name::Variable
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
rule %r/(else\b)([\t ]+)((?:ifn?def|ifn?eq)\b)([\t ]+)([^#\n]+)/ do
|
|
44
|
+
groups Keyword, Text, Keyword, Text, Name::Variable
|
|
45
|
+
end
|
|
46
|
+
|
|
43
47
|
rule %r/(?:else|endif|endef|endfor)[\t ]*(?=[#\n])/, Keyword
|
|
44
48
|
|
|
45
49
|
rule %r/(export)([\t ]+)(?=[\w\${}()\t -]+\n)/ do
|
|
@@ -73,7 +77,7 @@ module Rouge
|
|
|
73
77
|
end
|
|
74
78
|
|
|
75
79
|
state :export do
|
|
76
|
-
rule %r/[\w
|
|
80
|
+
rule %r/[\w\${}()-]/, Name::Variable
|
|
77
81
|
rule %r/\n/, Text, :pop!
|
|
78
82
|
rule %r/[\t ]+/, Text
|
|
79
83
|
end
|
|
@@ -107,7 +107,8 @@ module Rouge
|
|
|
107
107
|
push :link
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
rule %r/[*]
|
|
110
|
+
rule %r/[*]{2}[^* \n][^*\n]*[*]{2}/, Generic::Strong
|
|
111
|
+
rule %r/[*]{3}[^* \n][^*\n]*[*]{3}/, Generic::EmphStrong
|
|
111
112
|
rule %r/__#{edot}*?__/, Generic::Strong
|
|
112
113
|
|
|
113
114
|
rule %r/[*]#{edot}*?[*]/, Generic::Emph
|
|
@@ -7,7 +7,7 @@ module Rouge
|
|
|
7
7
|
title "Mathematica"
|
|
8
8
|
desc "Wolfram Mathematica, the world's definitive system for modern technical computing."
|
|
9
9
|
tag 'mathematica'
|
|
10
|
-
aliases 'wl'
|
|
10
|
+
aliases 'wl', 'wolfram'
|
|
11
11
|
filenames '*.m', '*.wl'
|
|
12
12
|
mimetypes 'application/vnd.wolfram.mathematica.package', 'application/vnd.wolfram.wl'
|
|
13
13
|
|
data/lib/rouge/lexers/meson.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
load_lexer 'python.rb'
|
|
7
|
+
|
|
8
|
+
class Mojo < Python
|
|
9
|
+
title "Mojo"
|
|
10
|
+
desc "The Mojo programming language (modular.com)"
|
|
11
|
+
tag 'mojo'
|
|
12
|
+
aliases 'mojo'
|
|
13
|
+
filenames '*.mojo', '*.🔥'
|
|
14
|
+
mimetypes 'text/x-mojo', 'application/x-mojo'
|
|
15
|
+
|
|
16
|
+
def self.detect?(text)
|
|
17
|
+
return true if text.shebang?(/mojow?(?:[23](?:\.\d+)?)?/)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.keywords
|
|
21
|
+
@keywords ||= super + %w(
|
|
22
|
+
fn self alias out read mut owned ref var
|
|
23
|
+
struct trait raises with in match case
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.builtins
|
|
28
|
+
@builtins ||= super + %w(
|
|
29
|
+
__mlir_attr __mlir_type __mlir_op parameter alwaysinline
|
|
30
|
+
register_passable
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/rouge/lexers/nasm.rb
CHANGED
|
@@ -14,11 +14,12 @@ module Rouge
|
|
|
14
14
|
mimetypes 'text/x-nasm'
|
|
15
15
|
|
|
16
16
|
state :root do
|
|
17
|
-
|
|
17
|
+
rule %r/^\s*%/, Comment::Preproc, :preproc
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
mixin :whitespace
|
|
20
|
+
mixin :punctuation
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label
|
|
22
23
|
|
|
23
24
|
rule %r/([a-z$._?][\w$.?#@~]*)(\s+)(equ)/i do
|
|
24
25
|
groups Name::Constant, Keyword::Declaration, Keyword::Declaration
|
|
@@ -32,7 +33,7 @@ module Rouge
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
state :instruction_args do
|
|
35
|
-
|
|
36
|
+
rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str
|
|
36
37
|
rule %r/(?:0x[\da-f]+|$0[\da-f]*|\d+[\da-f]*h)/i, Num::Hex
|
|
37
38
|
rule %r/[0-7]+q/i, Num::Oct
|
|
38
39
|
rule %r/[01]+b/i, Num::Bin
|
data/lib/rouge/lexers/nginx.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Rouge
|
|
|
12
12
|
tag 'objective_c'
|
|
13
13
|
title "Objective-C"
|
|
14
14
|
desc 'an extension of C commonly used to write Apple software'
|
|
15
|
-
aliases 'objc', 'obj-c', 'obj_c', 'objectivec'
|
|
15
|
+
aliases 'objc', 'obj-c', 'obj_c', 'objectivec', 'objective-c'
|
|
16
16
|
filenames '*.m', '*.h'
|
|
17
17
|
|
|
18
18
|
mimetypes 'text/x-objective_c', 'application/x-objective_c'
|
data/lib/rouge/lexers/ocl.rb
CHANGED
|
@@ -61,9 +61,9 @@ module Rouge
|
|
|
61
61
|
rule %r/--.*/, Comment::Single
|
|
62
62
|
rule %r/\d+/, Num::Integer
|
|
63
63
|
rule %r/'/, Str::Single, :single_string
|
|
64
|
-
rule %r([
|
|
64
|
+
rule %r([-|+*/<>=~!@#%&?^]), Operator
|
|
65
65
|
rule %r/[;:()\[\],.]/, Punctuation
|
|
66
|
-
rule %r
|
|
66
|
+
rule %r/[a-zA-Z]\w*/ do |m|
|
|
67
67
|
if self.class.operators.include? m[0]
|
|
68
68
|
token Operator
|
|
69
69
|
elsif self.class.keywords_type.include? m[0]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
class P4 < RegexLexer
|
|
7
|
+
tag 'p4'
|
|
8
|
+
title 'P4'
|
|
9
|
+
desc 'The P4 programming language'
|
|
10
|
+
filenames '*.p4'
|
|
11
|
+
mimetypes 'text/x-p4'
|
|
12
|
+
|
|
13
|
+
def self.keywords
|
|
14
|
+
@keywords ||= %w(
|
|
15
|
+
abstract action actions apply const default default_action else enum
|
|
16
|
+
entries extern exit if in inout key list out package packet_in
|
|
17
|
+
packet_out return size select switch this transition tuple type
|
|
18
|
+
typedef
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.operators
|
|
23
|
+
@operators ||= %w(
|
|
24
|
+
\|\+\| \|-\| \? \& \&\&\& < > << >> \* \| ~ \^ - \+ /
|
|
25
|
+
\# \. = != <= >= \+\+
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.decls
|
|
30
|
+
@decls ||= %w(
|
|
31
|
+
control header header_union parser state struct table
|
|
32
|
+
value_set
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.builtins
|
|
37
|
+
@builtins ||= %w(
|
|
38
|
+
bit bool error extract int isValid setValid setInvalid match_kind
|
|
39
|
+
string varbit verify void
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
state :whitespace do
|
|
44
|
+
rule %r/\s+/m, Text
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
state :comment do
|
|
48
|
+
rule %r((//).*$\n?), Comment::Single
|
|
49
|
+
rule %r/\/\*(?:(?!\*\/).)*\*\//m, Comment::Multiline
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
state :number do
|
|
53
|
+
rule %r/([0-9]+[sw])?0[oO][0-7_]+/, Num
|
|
54
|
+
rule %r/([0-9]+[sw])?0[xX][0-9a-fA-F_]+/, Num
|
|
55
|
+
rule %r/([0-9]+[sw])?0[bB][01_]+/, Num
|
|
56
|
+
rule %r/([0-9]+[sw])?0[dD][0-9_]+/, Num
|
|
57
|
+
rule %r/([0-9]+[sw])?[0-9_]+/, Num
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
id = /[\p{XID_Start}_]\p{XID_Continue}*/
|
|
61
|
+
string_element = /\\"|[^"]/x
|
|
62
|
+
|
|
63
|
+
state :root do
|
|
64
|
+
mixin :whitespace
|
|
65
|
+
mixin :comment
|
|
66
|
+
|
|
67
|
+
rule %r/#\s*#{id}/, Comment::Preproc
|
|
68
|
+
rule %r/\b(?:#{P4.keywords.join('|')})\b/, Keyword
|
|
69
|
+
rule %r/\b(?:#{P4.decls.join('|')})\b/, Keyword::Declaration
|
|
70
|
+
rule %r/\b(?:#{P4.builtins.join('|')})\b/, Name::Builtin
|
|
71
|
+
rule %r/\b#{id}_[th]\b/x, Name::Class
|
|
72
|
+
rule %r/(?:#{P4.operators.join('|')})/x, Operator
|
|
73
|
+
rule %r/[(){}\[\]<>,:;\.]/, Punctuation
|
|
74
|
+
mixin :number
|
|
75
|
+
rule %r/@#{id}/x, Name::Label
|
|
76
|
+
rule %r/#{id}/x, Text
|
|
77
|
+
rule %r/"(?: #{string_element} )*"/x, Str::String
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|