rouge 3.19.0 → 3.21.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/demos/augeas +16 -0
  3. data/lib/rouge/demos/bibtex +12 -0
  4. data/lib/rouge/demos/brightscript +6 -0
  5. data/lib/rouge/demos/hlsl +20 -0
  6. data/lib/rouge/demos/janet +3 -0
  7. data/lib/rouge/demos/livescript +15 -0
  8. data/lib/rouge/demos/ssh +4 -0
  9. data/lib/rouge/demos/velocity +9 -0
  10. data/lib/rouge/demos/zig +6 -0
  11. data/lib/rouge/lexers/augeas.rb +93 -0
  12. data/lib/rouge/lexers/batchfile.rb +1 -1
  13. data/lib/rouge/lexers/bibtex.rb +115 -0
  14. data/lib/rouge/lexers/brightscript.rb +147 -0
  15. data/lib/rouge/lexers/cpp.rb +11 -4
  16. data/lib/rouge/lexers/css.rb +3 -1
  17. data/lib/rouge/lexers/diff.rb +1 -1
  18. data/lib/rouge/lexers/docker.rb +1 -1
  19. data/lib/rouge/lexers/haskell.rb +27 -19
  20. data/lib/rouge/lexers/hlsl.rb +166 -0
  21. data/lib/rouge/lexers/html.rb +7 -7
  22. data/lib/rouge/lexers/janet.rb +217 -0
  23. data/lib/rouge/lexers/javascript.rb +3 -3
  24. data/lib/rouge/lexers/jinja.rb +22 -7
  25. data/lib/rouge/lexers/jsx.rb +47 -59
  26. data/lib/rouge/lexers/julia.rb +4 -2
  27. data/lib/rouge/lexers/livescript.rb +310 -0
  28. data/lib/rouge/lexers/opentype_feature_file.rb +27 -42
  29. data/lib/rouge/lexers/perl.rb +21 -3
  30. data/lib/rouge/lexers/powershell.rb +5 -3
  31. data/lib/rouge/lexers/rego.rb +27 -12
  32. data/lib/rouge/lexers/sass/common.rb +1 -0
  33. data/lib/rouge/lexers/ssh.rb +33 -0
  34. data/lib/rouge/lexers/tsx.rb +10 -3
  35. data/lib/rouge/lexers/twig.rb +4 -4
  36. data/lib/rouge/lexers/typescript.rb +1 -12
  37. data/lib/rouge/lexers/typescript/common.rb +18 -4
  38. data/lib/rouge/lexers/velocity.rb +71 -0
  39. data/lib/rouge/lexers/xml.rb +5 -3
  40. data/lib/rouge/lexers/yaml.rb +5 -3
  41. data/lib/rouge/lexers/zig.rb +139 -0
  42. data/lib/rouge/version.rb +1 -1
  43. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31311a77cd2c1bbe0bd0eb402b7b5d0e08c46a91fb9ae7614310b5c022f7707c
4
- data.tar.gz: daa405b54f1c0a249a57d6f5044e52a08a861aece022df92ee311492cfd6d553
3
+ metadata.gz: 8ef1072cc2523dba637a191d195865b0b2fb9f38c4f6d9961fb58748306f6cd1
4
+ data.tar.gz: 4cd1b0d5262fa8a1d4ddb564cf4e9a185d6e8043bee0261f119e7a8ccb81e1fd
5
5
  SHA512:
6
- metadata.gz: 27a79b06908ec8791d6e743817c35dae531e0b171cd35efa43190b384fbb87c74a72fbf5226b233ce8f96e57e2dc31596d91f5bb43307628c41da901544f649f
7
- data.tar.gz: 2bdf4c0aa72e72944e28428ac4c5eea314b01fd3314f037f107f80e43f125471cab7dc1d82ff055337015e231495fa781c6fd0a80db2c6a702346bea915b38af
6
+ metadata.gz: 04a39cda7513ce8084b6cdddd3016e7ca679218688dfb2dcb6f6fd8a0e627ec189f38a31ba2c44bd2a8c5b16191e24d0f343f860db5dfbcbb7ca49b92aaff197
7
+ data.tar.gz: 50172d87860fa9fb4b187dee66c72954ce926e0d73f3e78e1a15a7f3437e749d48b2f935fa6ad08be457a6dd317a3c5c20340a7f7cc1621825b97887e82822c1
@@ -0,0 +1,16 @@
1
+ (*
2
+ This is a comment
3
+ *)
4
+ module Foo =
5
+ autoload xfm
6
+
7
+ let a = b | c . d
8
+
9
+ let lns = a*
10
+
11
+ let filter = incl "/path/to/file"
12
+ . incl "/path/to/other_file"
13
+ . Util.stdexcl
14
+
15
+ (* xmf is the transform *)
16
+ let xmf = transform lns filter
@@ -0,0 +1,12 @@
1
+ @article{Witten:1988hf,
2
+ author = "Witten, Edward",
3
+ title = "{Quantum Field Theory and the Jones Polynomial}",
4
+ journal = "Commun. Math. Phys.",
5
+ volume = "121",
6
+ year = "1989",
7
+ pages = "351-399",
8
+ doi = "10.1007/BF01217730",
9
+ note = "[,233(1988)]",
10
+ reportNumber = "IASSNS-HEP-88-33",
11
+ SLACcitation = "%%CITATION = CMPHA,121,351;%%"
12
+ }
@@ -0,0 +1,6 @@
1
+ function main(args as dynamic) as void
2
+ screen = CreateObject("roSGScreen")
3
+ 'Create a scene and load /components/helloworld.xml'
4
+ scene = screen.CreateScene("HelloWorld")
5
+ screen.show()
6
+ end function
@@ -0,0 +1,20 @@
1
+ struct PSInput
2
+ {
3
+ float4 position : SV_POSITION;
4
+ float4 color : COLOR;
5
+ };
6
+
7
+ // Vertex shader
8
+ PSInput VSMain(float4 position : POSITION, float4 color : COLOR)
9
+ {
10
+ PSInput result;
11
+ result.position = position;
12
+ result.color = color;
13
+ return result;
14
+ }
15
+
16
+ // Pixel shader
17
+ float4 PSMain(PSInput input) : SV_TARGET
18
+ {
19
+ return input.color;
20
+ }
@@ -0,0 +1,3 @@
1
+ (defn a-fun
2
+ "A function"
3
+ (do-something))
@@ -0,0 +1,15 @@
1
+ mitch =
2
+ age: 21
3
+ height: 180cm
4
+ pets: [\dog, \goldfish]
5
+
6
+ phile = {}
7
+ phile{height, pets} = mitch
8
+ phile.height #=> 180
9
+ phile.pets #=> ['dog', 'goldfish']
10
+
11
+ a = [2 7 1 8]
12
+ ..push 3
13
+ ..shift!
14
+ ..sort!
15
+ a #=> [1,3,7,8]
@@ -0,0 +1,4 @@
1
+ Host example
2
+ Hostname example.com
3
+ User user
4
+ Port 1234
@@ -0,0 +1,9 @@
1
+ #*
2
+ There is multi-line comment.
3
+ see this text because the Velocity Templating Engine will ignore it.
4
+ *#
5
+ <h3>List</h3>
6
+ ## This is a single line comment.
7
+ #if( $allProducts )
8
+ <p>not found.</p>
9
+ #end
@@ -0,0 +1,6 @@
1
+ const std = @import("std");
2
+ const warn = std.debug.warn;
3
+
4
+ fn add_floats(x: f16, y: f16) f16 {
5
+ return x + y;
6
+ }
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Augeas < RegexLexer
7
+ title "Augeas"
8
+ desc "The Augeas programming language (augeas.net)"
9
+
10
+ tag 'augeas'
11
+ aliases 'aug'
12
+ filenames '*.aug'
13
+ mimetypes 'text/x-augeas'
14
+
15
+ def self.reserved
16
+ @reserved ||= Set.new %w(
17
+ _ let del store value counter seq key label autoload incl excl
18
+ transform test get put in after set clear insa insb print_string
19
+ print_regexp print_endline print_tree lens_ctype lens_atype
20
+ lens_ktype lens_vtype lens_format_atype regexp_match
21
+ )
22
+ end
23
+
24
+ state :basic do
25
+ rule %r/\s+/m, Text
26
+ rule %r/\(\*/, Comment::Multiline, :comment
27
+ end
28
+
29
+ state :comment do
30
+ rule %r/\*\)/, Comment::Multiline, :pop!
31
+ rule %r/\(\*/, Comment::Multiline, :comment
32
+ rule %r/[^*)]+/, Comment::Multiline
33
+ rule %r/[*)]/, Comment::Multiline
34
+ end
35
+
36
+ state :root do
37
+ mixin :basic
38
+
39
+ rule %r/(:)(\w\w*)/ do
40
+ groups Punctuation, Keyword::Type
41
+ end
42
+
43
+ rule %r/\w[\w']*/ do |m|
44
+ name = m[0]
45
+ if name == "module"
46
+ token Keyword::Reserved
47
+ push :module
48
+ elsif self.class.reserved.include? name
49
+ token Keyword::Reserved
50
+ elsif name =~ /\A[A-Z]/
51
+ token Keyword::Namespace
52
+ else
53
+ token Name
54
+ end
55
+ end
56
+
57
+ rule %r/"/, Str, :string
58
+ rule %r/\//, Str, :regexp
59
+
60
+ rule %r([-*+.=?\|]+), Operator
61
+ rule %r/[\[\](){}:;]/, Punctuation
62
+ end
63
+
64
+ state :module do
65
+ rule %r/\s+/, Text
66
+ rule %r/[A-Z][a-zA-Z0-9_.]*/, Name::Namespace, :pop!
67
+ end
68
+
69
+ state :regexp do
70
+ rule %r/\//, Str::Regex, :pop!
71
+ rule %r/[^\\\/]+/, Str::Regex
72
+ rule %r/\\[\\\/]/, Str::Regex
73
+ rule %r/\\/, Str::Regex
74
+ end
75
+
76
+ state :string do
77
+ rule %r/"/, Str, :pop!
78
+ rule %r/\\/, Str::Escape, :escape
79
+ rule %r/[^\\"]+/, Str
80
+ end
81
+
82
+ state :escape do
83
+ rule %r/[abfnrtv"'&\\]/, Str::Escape, :pop!
84
+ rule %r/\^[\]\[A-Z@\^_]/, Str::Escape, :pop!
85
+ rule %r/o[0-7]+/i, Str::Escape, :pop!
86
+ rule %r/x[\da-f]+/i, Str::Escape, :pop!
87
+ rule %r/\d+/, Str::Escape, :pop!
88
+ rule %r/\s+/, Str::Escape, :pop!
89
+ rule %r/./, Str, :pop!
90
+ end
91
+ end
92
+ end
93
+ end
@@ -78,7 +78,7 @@ module Rouge
78
78
 
79
79
  state :basic do
80
80
  # Comments
81
- rule %r/\brem\b.*$/i, Comment
81
+ rule %r/@?\brem\b.*$/i, Comment
82
82
  # Empty Labels
83
83
  rule %r/^::.*$/, Comment
84
84
 
@@ -0,0 +1,115 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ # Regular expressions based on https://github.com/SaswatPadhi/prismjs-bibtex
5
+ # and https://github.com/alecthomas/chroma/blob/master/lexers/b/bibtex.go
6
+
7
+ module Rouge
8
+ module Lexers
9
+ class BibTeX < RegexLexer
10
+ title 'BibTeX'
11
+ desc "BibTeX"
12
+ tag 'bibtex'
13
+ aliases 'bib'
14
+ filenames '*.bib'
15
+
16
+ valid_punctuation = Regexp.quote("@!$&.\\:;<>?[]^`|~*/+-")
17
+ valid_name = /[a-z_#{valid_punctuation}][\w#{valid_punctuation}]*/io
18
+
19
+ state :root do
20
+ mixin :whitespace
21
+
22
+ rule %r/@(#{valid_name})/o do |m|
23
+ match = m[1].downcase
24
+
25
+ if match == "comment"
26
+ token Comment
27
+ elsif match == "preamble"
28
+ token Name::Class
29
+ push :closing_brace
30
+ push :value
31
+ push :opening_brace
32
+ elsif match == "string"
33
+ token Name::Class
34
+ push :closing_brace
35
+ push :field
36
+ push :opening_brace
37
+ else
38
+ token Name::Class
39
+ push :closing_brace
40
+ push :command_body
41
+ push :opening_brace
42
+ end
43
+ end
44
+
45
+ rule %r/.+/, Comment
46
+ end
47
+
48
+ state :opening_brace do
49
+ mixin :whitespace
50
+ rule %r/[{(]/, Punctuation, :pop!
51
+ end
52
+
53
+ state :closing_brace do
54
+ mixin :whitespace
55
+ rule %r/[})]/, Punctuation, :pop!
56
+ end
57
+
58
+ state :command_body do
59
+ mixin :whitespace
60
+ rule %r/[^\s\,\}]+/ do
61
+ token Name::Label
62
+ pop!
63
+ push :fields
64
+ end
65
+ end
66
+
67
+ state :fields do
68
+ mixin :whitespace
69
+ rule %r/,/, Punctuation, :field
70
+ rule(//) { pop! }
71
+ end
72
+
73
+ state :field do
74
+ mixin :whitespace
75
+ rule valid_name do
76
+ token Name::Attribute
77
+ push :value
78
+ push :equal_sign
79
+ end
80
+ rule(//) { pop! }
81
+ end
82
+
83
+ state :equal_sign do
84
+ mixin :whitespace
85
+ rule %r/=/, Punctuation, :pop!
86
+ end
87
+
88
+ state :value do
89
+ mixin :whitespace
90
+ rule valid_name, Name::Variable
91
+ rule %r/"/, Literal::String, :quoted_string
92
+ rule %r/\{/, Literal::String, :braced_string
93
+ rule %r/\d+/, Literal::Number
94
+ rule %r/#/, Punctuation
95
+ rule(//) { pop! }
96
+ end
97
+
98
+ state :quoted_string do
99
+ rule %r/\{/, Literal::String, :braced_string
100
+ rule %r/"/, Literal::String, :pop!
101
+ rule %r/[^\{\"]+/, Literal::String
102
+ end
103
+
104
+ state :braced_string do
105
+ rule %r/\{/, Literal::String, :braced_string
106
+ rule %r/\}/, Literal::String, :pop!
107
+ rule %r/[^\{\}]+/, Literal::String
108
+ end
109
+
110
+ state :whitespace do
111
+ rule %r/\s+/, Text
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Brightscript < RegexLexer
7
+ title "BrightScript"
8
+ desc "BrightScript Programming Language (https://developer.roku.com/en-ca/docs/references/brightscript/language/brightscript-language-reference.md)"
9
+ tag 'brightscript'
10
+ aliases 'bs', 'brs'
11
+ filenames '*.brs'
12
+
13
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md
14
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-string-functions.md
15
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-math-functions.md
16
+ def self.name_builtin
17
+ @name_builtin ||= Set.new %w(
18
+ ABS ASC ATN CDBL CHR CINT CONTROL COPYFILE COS CREATEDIRECTORY CSNG
19
+ DELETEDIRECTORY DELETEFILE EXP FINDMEMBERFUNCTION FINDNODE FIX
20
+ FORMATDRIVEFORMATJSON GETINTERFACE INSTR INT LCASE LEFT LEN LISTDIR
21
+ LOG MATCHFILES MID MOVEFILE OBSERVEFIELD PARSEJSON PARSEXML
22
+ READASCIIFILE REBOOTSYSTEM RIGHT RND RUNGARBAGECOLLECTOR SGN SIN
23
+ SLEEP SQR STR STRI STRING STRINGI STRTOI SUBSTITUTE TANTEXTTOP TEXT
24
+ TRUCASE UPTIME VALVISIBLE VISIBLE WAIT
25
+ )
26
+ end
27
+
28
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/reserved-words.md
29
+ def self.keyword_reserved
30
+ @keyword_reserved ||= Set.new %w(
31
+ BOX CREATEOBJECT DIM EACH ELSE ELSEIF END ENDFUNCTION ENDIF ENDSUB
32
+ ENDWHILE EVAL EXIT EXITWHILE FALSE FOR FUNCTION GETGLOBALAA
33
+ GETLASTRUNCOMPILEERROR GETLASTRUNRUNTIMEERROR GOTO IF IN INVALID LET
34
+ LINE_NUM M NEXT OBJFUN POS PRINT REM RETURN RUN STEP STOP SUB TAB TO
35
+ TRUE TYPE WHILE
36
+ )
37
+ end
38
+
39
+ # These keywords are present in BrightScript, but not supported in standard .brs files
40
+ def self.keyword_reserved_unsupported
41
+ @keyword_reserved_unsupported ||= Set.new %w(
42
+ CLASS CONST IMPORT LIBRARY NAMESPACE PRIVATE PROTECTED PUBLIC
43
+ )
44
+ end
45
+
46
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md
47
+ def self.keyword_type
48
+ @keyword_type ||= Set.new %w(
49
+ BOOLEAN DIM DOUBLE DYNAMIC FLOAT FUNCTION INTEGER INTERFACE INVALID
50
+ LONGINTEGER OBJECT STRING VOID
51
+ )
52
+ end
53
+
54
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
55
+ def self.operator_word
56
+ @operator_word ||= Set.new %w(
57
+ AND AS MOD NOT OR THEN
58
+ )
59
+ end
60
+
61
+ # Scene graph components configured as builtins. See BrightScript component documentation e.g.
62
+ # https://developer.roku.com/en-ca/docs/references/brightscript/components/roappinfo.md
63
+ def self.builtins
64
+ @builtins ||= Set.new %w(
65
+ roAppendFile roAppInfo roAppManager roArray roAssociativeArray
66
+ roAudioGuide roAudioMetadata roAudioPlayer roAudioPlayerEvent
67
+ roAudioResourceroBitmap roBoolean roBoolean roBrightPackage roBrSub
68
+ roButton roByteArray roCaptionRenderer roCaptionRendererEvent
69
+ roCecInterface roCECStatusEvent roChannelStore roChannelStoreEvent
70
+ roClockWidget roCodeRegistrationScreen
71
+ roCodeRegistrationScreenEventroCompositor roControlDown roControlPort
72
+ roControlPort roControlUp roCreateFile roDatagramReceiver
73
+ roDatagramSender roDataGramSocket roDateTime roDeviceInfo
74
+ roDeviceInfoEvent roDoubleroEVPCipher roEVPDigest roFileSystem
75
+ roFileSystemEvent roFloat roFont roFontMetrics roFontRegistry
76
+ roFunction roGlobal roGpio roGridScreen roGridScreenEvent
77
+ roHdmiHotPlugEventroHdmiStatus roHdmiStatusEvent roHMAC roHttpAgent
78
+ roImageCanvas roImageCanvasEvent roImageMetadata roImagePlayer
79
+ roImageWidgetroInput roInputEvent roInt roInt roInvalid roInvalid
80
+ roIRRemote roKeyboard roKeyboardPress roKeyboardScreen
81
+ roKeyboardScreenEventroList roListScreen roListScreenEvent
82
+ roLocalization roLongInteger roMessageDialog roMessageDialogEvent
83
+ roMessagePort roMicrophone roMicrophoneEvent roNetworkConfiguration
84
+ roOneLineDialog roOneLineDialogEventroParagraphScreen
85
+ roParagraphScreenEvent roPath roPinEntryDialog roPinEntryDialogEvent
86
+ roPinentryScreen roPosterScreen roPosterScreenEventroProgramGuide
87
+ roQuadravoxButton roReadFile roRectangleroRegexroRegion roRegistry
88
+ roRegistrySection roResourceManager roRSA roRssArticle roRssParser
89
+ roScreen roSearchHistory roSearchScreen roSearchScreenEvent
90
+ roSerialPort roSGNode roSGNodeEvent roSGScreenroSGScreenEvent
91
+ roSlideShowroSlideShowEvent roSNS5 roSocketAddress roSocketEvent
92
+ roSpringboardScreen roSpringboardScreenEventroSprite roStorageInfo
93
+ roStreamSocket roStringroSystemLogroSystemLogEvent roSystemTime
94
+ roTextFieldroTextScreen roTextScreenEvent roTextToSpeech
95
+ roTextToSpeechEvent roTextureManager roTextureRequest
96
+ roTextureRequestEventroTextWidget roTimer roTimespan roTouchScreen
97
+ roTunerroTunerEvent roUniversalControlEvent roUrlEvent roUrlTransfer
98
+ roVideoEvent roVideoInput roVideoMode roVideoPlayer roVideoPlayerEvent
99
+ roVideoScreen roVideoScreenEventroWriteFile roXMLElement roXMLList
100
+ )
101
+ end
102
+
103
+ id = /[$a-z_][a-z0-9_]*/io
104
+
105
+ state :root do
106
+ rule %r/\s+/m, Text::Whitespace
107
+
108
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#comments
109
+ rule %r/\'.*/, Comment::Single
110
+ rule %r/REM.*/i, Comment::Single
111
+
112
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
113
+ rule %r([~!%^&*+=\|?:<>/-]), Operator
114
+
115
+ rule %r/\d*\.\d+(e-?\d+)?/i, Num::Float
116
+ rule %r/\d+[lu]*/i, Num::Integer
117
+
118
+ rule %r/".*?"/, Str::Double
119
+
120
+ rule %r/#{id}(?=\s*[(])/, Name::Function
121
+
122
+ rule %r/[()\[\],.;{}]/, Punctuation
123
+
124
+ rule id do |m|
125
+ caseSensitiveChunk = m[0]
126
+ caseInsensitiveChunk = m[0].upcase
127
+
128
+ if self.class.builtins.include?(caseSensitiveChunk)
129
+ token Keyword::Reserved
130
+ elsif self.class.keyword_reserved.include?(caseInsensitiveChunk)
131
+ token Keyword::Reserved
132
+ elsif self.class.keyword_reserved_unsupported.include?(caseInsensitiveChunk)
133
+ token Keyword::Reserved
134
+ elsif self.class.keyword_type.include?(caseInsensitiveChunk)
135
+ token Keyword::Type
136
+ elsif self.class.name_builtin.include?(caseInsensitiveChunk)
137
+ token Name::Builtin
138
+ elsif self.class.operator_word.include?(caseInsensitiveChunk)
139
+ token Operator::Word
140
+ else
141
+ token Name
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end