rouge 3.15.0 → 3.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rougify +2 -2
- data/lib/rouge.rb +67 -52
- data/lib/rouge/cli.rb +18 -1
- data/lib/rouge/demos/augeas +16 -0
- data/lib/rouge/demos/bibtex +12 -0
- data/lib/rouge/demos/cypher +5 -0
- data/lib/rouge/demos/datastudio +21 -0
- data/lib/rouge/demos/ecl +18 -0
- data/lib/rouge/demos/ghc-cmm +23 -0
- data/lib/rouge/demos/hlsl +20 -0
- data/lib/rouge/demos/isbl +4 -0
- data/lib/rouge/demos/livescript +15 -0
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/rego +8 -0
- data/lib/rouge/demos/solidity +13 -0
- data/lib/rouge/demos/vcl +12 -0
- data/lib/rouge/demos/velocity +9 -0
- data/lib/rouge/demos/yang +17 -0
- data/lib/rouge/demos/zig +6 -0
- data/lib/rouge/formatters/terminal256.rb +22 -6
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/lexer.rb +4 -2
- data/lib/rouge/lexers/apache.rb +22 -12
- data/lib/rouge/lexers/apache/keywords.rb +24 -0
- data/lib/rouge/lexers/augeas.rb +93 -0
- data/lib/rouge/lexers/bibtex.rb +115 -0
- data/lib/rouge/lexers/cmake.rb +1 -0
- data/lib/rouge/lexers/coffeescript.rb +47 -15
- data/lib/rouge/lexers/console.rb +53 -37
- data/lib/rouge/lexers/cpp.rb +18 -5
- data/lib/rouge/lexers/cypher.rb +108 -0
- data/lib/rouge/lexers/d.rb +3 -3
- data/lib/rouge/lexers/datastudio.rb +138 -0
- data/lib/rouge/lexers/diff.rb +1 -1
- data/lib/rouge/lexers/ecl.rb +175 -0
- data/lib/rouge/lexers/fsharp.rb +1 -0
- data/lib/rouge/lexers/ghc_cmm.rb +340 -0
- data/lib/rouge/lexers/gherkin.rb +1 -1
- data/lib/rouge/lexers/gherkin/keywords.rb +9 -6
- data/lib/rouge/lexers/haskell.rb +27 -19
- data/lib/rouge/lexers/hlsl.rb +166 -0
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/isbl.rb +97 -0
- data/lib/rouge/lexers/isbl/builtins.rb +17 -0
- data/lib/rouge/lexers/java.rb +4 -5
- data/lib/rouge/lexers/javascript.rb +1 -3
- data/lib/rouge/lexers/json.rb +3 -0
- data/lib/rouge/lexers/json_doc.rb +1 -0
- data/lib/rouge/lexers/jsx.rb +47 -59
- data/lib/rouge/lexers/kotlin.rb +14 -2
- data/lib/rouge/lexers/lasso.rb +11 -12
- data/lib/rouge/lexers/lasso/keywords.rb +20 -0
- data/lib/rouge/lexers/livescript.rb +310 -0
- data/lib/rouge/lexers/llvm.rb +6 -33
- data/lib/rouge/lexers/llvm/keywords.rb +25 -0
- data/lib/rouge/lexers/lua.rb +41 -3
- data/lib/rouge/lexers/lua/keywords.rb +28 -0
- data/lib/rouge/lexers/markdown.rb +9 -5
- data/lib/rouge/lexers/mathematica.rb +2 -2
- data/lib/rouge/lexers/mathematica/keywords.rb +17 -0
- data/lib/rouge/lexers/matlab.rb +3 -4
- data/lib/rouge/lexers/matlab/builtins.rb +11 -0
- data/lib/rouge/lexers/matlab/keywords.rb +15 -0
- data/lib/rouge/lexers/nasm.rb +42 -168
- data/lib/rouge/lexers/objective_c/common.rb +2 -2
- data/lib/rouge/lexers/opentype_feature_file.rb +27 -42
- data/lib/rouge/lexers/pascal.rb +1 -1
- data/lib/rouge/lexers/php.rb +48 -33
- data/lib/rouge/lexers/php/keywords.rb +202 -0
- data/lib/rouge/lexers/powershell.rb +7 -2
- data/lib/rouge/lexers/python.rb +58 -57
- data/lib/rouge/lexers/racket.rb +24 -1
- data/lib/rouge/lexers/rego.rb +45 -0
- data/lib/rouge/lexers/ruby.rb +16 -3
- data/lib/rouge/lexers/rust.rb +2 -10
- data/lib/rouge/lexers/scala.rb +1 -1
- data/lib/rouge/lexers/shell.rb +1 -1
- data/lib/rouge/lexers/solidity.rb +185 -0
- data/lib/rouge/lexers/sparql.rb +5 -4
- data/lib/rouge/lexers/sqf.rb +2 -2
- data/lib/rouge/lexers/sqf/keywords.rb +12 -0
- data/lib/rouge/lexers/terraform.rb +15 -0
- data/lib/rouge/lexers/toml.rb +23 -0
- data/lib/rouge/lexers/tsx.rb +10 -3
- data/lib/rouge/lexers/turtle.rb +1 -1
- data/lib/rouge/lexers/typescript.rb +1 -1
- data/lib/rouge/lexers/typescript/common.rb +18 -4
- data/lib/rouge/lexers/varnish.rb +168 -0
- data/lib/rouge/lexers/velocity.rb +71 -0
- data/lib/rouge/lexers/viml.rb +6 -38
- data/lib/rouge/lexers/viml/keywords.rb +11 -4
- data/lib/rouge/lexers/vue.rb +4 -1
- data/lib/rouge/lexers/yang.rb +147 -0
- data/lib/rouge/lexers/zig.rb +139 -0
- data/lib/rouge/version.rb +1 -1
- metadata +43 -9
- data/lib/rouge/lexers/apache/keywords.yml +0 -764
- data/lib/rouge/lexers/lasso/keywords.yml +0 -446
- data/lib/rouge/lexers/lua/builtins.rb +0 -24
- data/lib/rouge/lexers/mathematica/builtins.rb +0 -13
- data/lib/rouge/lexers/matlab/builtins.yml +0 -3515
- data/lib/rouge/lexers/php/builtins.rb +0 -203
- data/lib/rouge/lexers/sqf/commands.rb +0 -15
@@ -24,10 +24,7 @@ module Rouge
|
|
24
24
|
|
25
25
|
def stream(tokens, &b)
|
26
26
|
tokens.each do |tok, val|
|
27
|
-
|
28
|
-
yield escape.style_string
|
29
|
-
yield val.gsub("\n", "#{escape.reset_string}\n#{escape.style_string}")
|
30
|
-
yield escape.reset_string
|
27
|
+
escape_sequence(tok).stream_value(val, &b)
|
31
28
|
end
|
32
29
|
end
|
33
30
|
|
@@ -85,6 +82,14 @@ module Rouge
|
|
85
82
|
@bg = style.bg && self.class.color_index(style.bg)
|
86
83
|
end
|
87
84
|
|
85
|
+
|
86
|
+
def stream_value(val, &b)
|
87
|
+
yield style_string
|
88
|
+
yield val.gsub("\e", "\\e")
|
89
|
+
.gsub("\n", "#{reset_string}\n#{style_string}")
|
90
|
+
yield reset_string
|
91
|
+
end
|
92
|
+
|
88
93
|
def style_string
|
89
94
|
@style_string ||= begin
|
90
95
|
attrs = []
|
@@ -157,12 +162,23 @@ module Rouge
|
|
157
162
|
end
|
158
163
|
end
|
159
164
|
|
165
|
+
class Unescape < EscapeSequence
|
166
|
+
def initialize(*) end
|
167
|
+
def style_string(*) '' end
|
168
|
+
def reset_string(*) '' end
|
169
|
+
def stream_value(val) yield val end
|
170
|
+
end
|
171
|
+
|
160
172
|
# private
|
161
173
|
def escape_sequence(token)
|
162
|
-
return
|
174
|
+
return Unescape.new if escape?(token)
|
163
175
|
@escape_sequences ||= {}
|
164
176
|
@escape_sequences[token.qualname] ||=
|
165
|
-
|
177
|
+
make_escape_sequence(get_style(token))
|
178
|
+
end
|
179
|
+
|
180
|
+
def make_escape_sequence(style)
|
181
|
+
EscapeSequence.new(style)
|
166
182
|
end
|
167
183
|
|
168
184
|
def get_style(token)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
module Rouge
|
4
|
+
module Formatters
|
5
|
+
class TerminalTruecolor < Terminal256
|
6
|
+
tag 'terminal_truecolor'
|
7
|
+
|
8
|
+
class TruecolorEscapeSequence < Terminal256::EscapeSequence
|
9
|
+
def style_string
|
10
|
+
@style_string ||= begin
|
11
|
+
out = String.new('')
|
12
|
+
out << escape(['48', '2', *get_rgb(style.bg)]) if style.bg
|
13
|
+
out << escape(['38', '2', *get_rgb(style.fg)]) if style.fg
|
14
|
+
out << escape(['1']) if style[:bold] || style[:italic]
|
15
|
+
out
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_rgb(color)
|
20
|
+
color = $1 if color =~ /#(\h+)/
|
21
|
+
|
22
|
+
case color.size
|
23
|
+
when 3 then color.chars.map { |c| c.to_i(16) * 2 }
|
24
|
+
when 6 then color.scan(/../).map { |cc| cc.to_i(16) }
|
25
|
+
else
|
26
|
+
raise "invalid color: #{color.inspect}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @override
|
32
|
+
def make_escape_sequence(style)
|
33
|
+
TruecolorEscapeSequence.new(style)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rouge/lexer.rb
CHANGED
@@ -209,7 +209,8 @@ module Rouge
|
|
209
209
|
# Determine if a lexer has a method named +:detect?+ defined in its
|
210
210
|
# singleton class.
|
211
211
|
def detectable?
|
212
|
-
@detectable
|
212
|
+
return @detectable if defined?(@detectable)
|
213
|
+
@detectable = singleton_methods(false).include?(:detect?)
|
213
214
|
end
|
214
215
|
|
215
216
|
protected
|
@@ -504,12 +505,13 @@ module Rouge
|
|
504
505
|
end
|
505
506
|
|
506
507
|
module Lexers
|
508
|
+
BASE_DIR = "#{__dir__}/lexers".freeze
|
507
509
|
@_loaded_lexers = {}
|
508
510
|
|
509
511
|
def self.load_lexer(relpath)
|
510
512
|
return if @_loaded_lexers.key?(relpath)
|
511
513
|
@_loaded_lexers[relpath] = true
|
512
|
-
load File.join(
|
514
|
+
Kernel::load File.join(BASE_DIR, relpath)
|
513
515
|
end
|
514
516
|
end
|
515
517
|
end
|
data/lib/rouge/lexers/apache.rb
CHANGED
@@ -11,18 +11,28 @@ module Rouge
|
|
11
11
|
mimetypes 'text/x-httpd-conf', 'text/x-apache-conf'
|
12
12
|
filenames '.htaccess', 'httpd.conf'
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
# self-modifying method that loads the keywords file
|
15
|
+
def self.directives
|
16
|
+
Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb')
|
17
|
+
directives
|
16
18
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
|
20
|
+
def self.sections
|
21
|
+
Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb')
|
22
|
+
sections
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.values
|
26
|
+
Kernel::load File.join(Lexers::BASE_DIR, 'apache/keywords.rb')
|
27
|
+
values
|
22
28
|
end
|
23
29
|
|
24
|
-
def name_for_token(token,
|
25
|
-
if self.class.
|
30
|
+
def name_for_token(token, tktype)
|
31
|
+
if self.class.sections.include? token
|
32
|
+
tktype
|
33
|
+
elsif self.class.directives.include? token
|
34
|
+
tktype
|
35
|
+
elsif self.class.values.include? token
|
26
36
|
tktype
|
27
37
|
else
|
28
38
|
Text
|
@@ -38,12 +48,12 @@ module Rouge
|
|
38
48
|
mixin :whitespace
|
39
49
|
|
40
50
|
rule %r/(<\/?)(\w+)/ do |m|
|
41
|
-
groups Punctuation, name_for_token(m[2].downcase,
|
51
|
+
groups Punctuation, name_for_token(m[2].downcase, Name::Label)
|
42
52
|
push :section
|
43
53
|
end
|
44
54
|
|
45
55
|
rule %r/\w+/ do |m|
|
46
|
-
token name_for_token(m[0].downcase,
|
56
|
+
token name_for_token(m[0].downcase, Name::Class)
|
47
57
|
push :directive
|
48
58
|
end
|
49
59
|
end
|
@@ -65,7 +75,7 @@ module Rouge
|
|
65
75
|
mixin :whitespace
|
66
76
|
|
67
77
|
rule %r/\S+/ do |m|
|
68
|
-
token name_for_token(m[0],
|
78
|
+
token name_for_token(m[0].downcase, Literal::String::Symbol)
|
69
79
|
end
|
70
80
|
end
|
71
81
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# DO NOT EDIT
|
5
|
+
# This file is automatically generated by `rake builtins:apache`.
|
6
|
+
# See tasks/builtins/apache.rake for more info.
|
7
|
+
|
8
|
+
module Rouge
|
9
|
+
module Lexers
|
10
|
+
class Apache
|
11
|
+
def self.directives
|
12
|
+
@directives ||= Set.new ["acceptfilter", "acceptpathinfo", "accessfilename", "action", "addalt", "addaltbyencoding", "addaltbytype", "addcharset", "adddefaultcharset", "adddescription", "addencoding", "addhandler", "addicon", "addiconbyencoding", "addiconbytype", "addinputfilter", "addlanguage", "addmoduleinfo", "addoutputfilter", "addoutputfilterbytype", "addtype", "alias", "aliasmatch", "allow", "allowconnect", "allowencodedslashes", "allowmethods", "allowoverride", "allowoverridelist", "anonymous", "anonymous_logemail", "anonymous_mustgiveemail", "anonymous_nouserid", "anonymous_verifyemail", "asyncrequestworkerfactor", "authbasicauthoritative", "authbasicfake", "authbasicprovider", "authbasicusedigestalgorithm", "authdbduserpwquery", "authdbduserrealmquery", "authdbmgroupfile", "authdbmtype", "authdbmuserfile", "authdigestalgorithm", "authdigestdomain", "authdigestnoncelifetime", "authdigestprovider", "authdigestqop", "authdigestshmemsize", "authformauthoritative", "authformbody", "authformdisablenostore", "authformfakebasicauth", "authformlocation", "authformloginrequiredlocation", "authformloginsuccesslocation", "authformlogoutlocation", "authformmethod", "authformmimetype", "authformpassword", "authformprovider", "authformsitepassphrase", "authformsize", "authformusername", "authgroupfile", "authldapauthorizeprefix", "authldapbindauthoritative", "authldapbinddn", "authldapbindpassword", "authldapcharsetconfig", "authldapcompareasuser", "authldapcomparednonserver", "authldapdereferencealiases", "authldapgroupattribute", "authldapgroupattributeisdn", "authldapinitialbindasuser", "authldapinitialbindpattern", "authldapmaxsubgroupdepth", "authldapremoteuserattribute", "authldapremoteuserisdn", "authldapsearchasuser", "authldapsubgroupattribute", "authldapsubgroupclass", "authldapurl", "authmerging", "authname", "authncachecontext", "authncacheenable", "authncacheprovidefor", "authncachesocache", "authncachetimeout", "authnzfcgicheckauthnprovider", "authnzfcgidefineprovider", "authtype", "authuserfile", "authzdbdlogintoreferer", "authzdbdquery", "authzdbdredirectquery", "authzdbmtype", "authzsendforbiddenonfailure", "balancergrowth", "balancerinherit", "balancermember", "balancerpersist", "brotlialteretag", "brotlicompressionmaxinputblock", "brotlicompressionquality", "brotlicompressionwindow", "brotlifilternote", "browsermatch", "browsermatchnocase", "bufferedlogs", "buffersize", "cachedefaultexpire", "cachedetailheader", "cachedirlength", "cachedirlevels", "cachedisable", "cacheenable", "cachefile", "cacheheader", "cacheignorecachecontrol", "cacheignoreheaders", "cacheignorenolastmod", "cacheignorequerystring", "cacheignoreurlsessionidentifiers", "cachekeybaseurl", "cachelastmodifiedfactor", "cachelock", "cachelockmaxage", "cachelockpath", "cachemaxexpire", "cachemaxfilesize", "cacheminexpire", "cacheminfilesize", "cachenegotiateddocs", "cachequickhandler", "cachereadsize", "cachereadtime", "cacheroot", "cachesocache", "cachesocachemaxsize", "cachesocachemaxtime", "cachesocachemintime", "cachesocachereadsize", "cachesocachereadtime", "cachestaleonerror", "cachestoreexpired", "cachestorenostore", "cachestoreprivate", "cgidscripttimeout", "cgimapextension", "cgipassauth", "cgivar", "charsetdefault", "charsetoptions", "charsetsourceenc", "checkcaseonly", "checkspelling", "chrootdir", "contentdigest", "cookiedomain", "cookieexpires", "cookiename", "cookiestyle", "cookietracking", "coredumpdirectory", "customlog", "dav", "davdepthinfinity", "davgenericlockdb", "davlockdb", "davmintimeout", "dbdexptime", "dbdinitsql", "dbdkeep", "dbdmax", "dbdmin", "dbdparams", "dbdpersist", "dbdpreparesql", "dbdriver", "defaulticon", "defaultlanguage", "defaultruntimedir", "defaulttype", "define", "deflatebuffersize", "deflatecompressionlevel", "deflatefilternote", "deflateinflatelimitrequestbody", "deflateinflateratioburst", "deflateinflateratiolimit", "deflatememlevel", "deflatewindowsize", "deny", "directorycheckhandler", "directoryindex", "directoryindexredirect", "directoryslash", "documentroot", "dtraceprivileges", "dumpioinput", "dumpiooutput", "enableexceptionhook", "enablemmap", "enablesendfile", "error", "errordocument", "errorlog", "errorlogformat", "example", "expiresactive", "expiresbytype", "expiresdefault", "extendedstatus", "extfilterdefine", "extfilteroptions", "fallbackresource", "fileetag", "filterchain", "filterdeclare", "filterprotocol", "filterprovider", "filtertrace", "forcelanguagepriority", "forcetype", "forensiclog", "globallog", "gprofdir", "gracefulshutdowntimeout", "group", "h2copyfiles", "h2direct", "h2earlyhints", "h2maxsessionstreams", "h2maxworkeridleseconds", "h2maxworkers", "h2minworkers", "h2moderntlsonly", "h2push", "h2pushdiarysize", "h2pushpriority", "h2pushresource", "h2serializeheaders", "h2streammaxmemsize", "h2tlscooldownsecs", "h2tlswarmupsize", "h2upgrade", "h2windowsize", "header", "headername", "heartbeataddress", "heartbeatlisten", "heartbeatmaxservers", "heartbeatstorage", "heartbeatstorage", "hostnamelookups", "httpprotocoloptions", "identitycheck", "identitychecktimeout", "imapbase", "imapdefault", "imapmenu", "include", "includeoptional", "indexheadinsert", "indexignore", "indexignorereset", "indexoptions", "indexorderdefault", "indexstylesheet", "inputsed", "isapiappendlogtoerrors", "isapiappendlogtoquery", "isapicachefile", "isapifakeasync", "isapilognotsupported", "isapireadaheadbuffer", "keepalive", "keepalivetimeout", "keptbodysize", "languagepriority", "ldapcacheentries", "ldapcachettl", "ldapconnectionpoolttl", "ldapconnectiontimeout", "ldaplibrarydebug", "ldapopcacheentries", "ldapopcachettl", "ldapreferralhoplimit", "ldapreferrals", "ldapretries", "ldapretrydelay", "ldapsharedcachefile", "ldapsharedcachesize", "ldaptimeout", "ldaptrustedclientcert", "ldaptrustedglobalcert", "ldaptrustedmode", "ldapverifyservercert", "limitinternalrecursion", "limitrequestbody", "limitrequestfields", "limitrequestfieldsize", "limitrequestline", "limitxmlrequestbody", "listen", "listenbacklog", "listencoresbucketsratio", "loadfile", "loadmodule", "logformat", "logiotrackttfb", "loglevel", "logmessage", "luaauthzprovider", "luacodecache", "luahookaccesschecker", "luahookauthchecker", "luahookcheckuserid", "luahookfixups", "luahookinsertfilter", "luahooklog", "luahookmaptostorage", "luahooktranslatename", "luahooktypechecker", "luainherit", "luainputfilter", "luamaphandler", "luaoutputfilter", "luapackagecpath", "luapackagepath", "luaquickhandler", "luaroot", "luascope", "maxconnectionsperchild", "maxkeepaliverequests", "maxmemfree", "maxrangeoverlaps", "maxrangereversals", "maxranges", "maxrequestworkers", "maxspareservers", "maxsparethreads", "maxthreads", "mdbaseserver", "mdcachallenges", "mdcertificateagreement", "mdcertificateauthority", "mdcertificateprotocol", "mddrivemode", "mdhttpproxy", "mdmember", "mdmembers", "mdmuststaple", "mdnotifycmd", "mdomain", "mdportmap", "mdprivatekeys", "mdrenewwindow", "mdrequirehttps", "mdstoredir", "memcacheconnttl", "mergetrailers", "metadir", "metafiles", "metasuffix", "mimemagicfile", "minspareservers", "minsparethreads", "mmapfile", "modemstandard", "modmimeusepathinfo", "multiviewsmatch", "mutex", "namevirtualhost", "noproxy", "nwssltrustedcerts", "nwsslupgradeable", "options", "order", "outputsed", "passenv", "pidfile", "privilegesmode", "protocol", "protocolecho", "protocols", "protocolshonororder", "proxyaddheaders", "proxybadheader", "proxyblock", "proxydomain", "proxyerroroverride", "proxyexpressdbmfile", "proxyexpressdbmtype", "proxyexpressenable", "proxyfcgibackendtype", "proxyfcgisetenvif", "proxyftpdircharset", "proxyftpescapewildcards", "proxyftplistonwildcard", "proxyhcexpr", "proxyhctemplate", "proxyhctpsize", "proxyhtmlbufsize", "proxyhtmlcharsetout", "proxyhtmldoctype", "proxyhtmlenable", "proxyhtmlevents", "proxyhtmlextended", "proxyhtmlfixups", "proxyhtmlinterp", "proxyhtmllinks", "proxyhtmlmeta", "proxyhtmlstripcomments", "proxyhtmlurlmap", "proxyiobuffersize", "proxymaxforwards", "proxypass", "proxypassinherit", "proxypassinterpolateenv", "proxypassmatch", "proxypassreverse", "proxypassreversecookiedomain", "proxypassreversecookiepath", "proxypreservehost", "proxyreceivebuffersize", "proxyremote", "proxyremotematch", "proxyrequests", "proxyscgiinternalredirect", "proxyscgisendfile", "proxyset", "proxysourceaddress", "proxystatus", "proxytimeout", "proxyvia", "qualifyredirecturl", "readmename", "receivebuffersize", "redirect", "redirectmatch", "redirectpermanent", "redirecttemp", "reflectorheader", "registerhttpmethod", "remoteipheader", "remoteipinternalproxy", "remoteipinternalproxylist", "remoteipproxiesheader", "remoteipproxyprotocol", "remoteipproxyprotocolexceptions", "remoteiptrustedproxy", "remoteiptrustedproxylist", "removecharset", "removeencoding", "removehandler", "removeinputfilter", "removelanguage", "removeoutputfilter", "removetype", "requestheader", "requestreadtimeout", "require", "rewritebase", "rewritecond", "rewriteengine", "rewritemap", "rewriteoptions", "rewriterule", "rlimitcpu", "rlimitmem", "rlimitnproc", "satisfy", "scoreboardfile", "script", "scriptalias", "scriptaliasmatch", "scriptinterpretersource", "scriptlog", "scriptlogbuffer", "scriptloglength", "scriptsock", "securelisten", "seerequesttail", "sendbuffersize", "serveradmin", "serveralias", "serverlimit", "servername", "serverpath", "serverroot", "serversignature", "servertokens", "session", "sessioncookiename", "sessioncookiename2", "sessioncookieremove", "sessioncryptocipher", "sessioncryptodriver", "sessioncryptopassphrase", "sessioncryptopassphrasefile", "sessiondbdcookiename", "sessiondbdcookiename2", "sessiondbdcookieremove", "sessiondbddeletelabel", "sessiondbdinsertlabel", "sessiondbdperuser", "sessiondbdselectlabel", "sessiondbdupdatelabel", "sessionenv", "sessionexclude", "sessionheader", "sessioninclude", "sessionmaxage", "setenv", "setenvif", "setenvifexpr", "setenvifnocase", "sethandler", "setinputfilter", "setoutputfilter", "ssiendtag", "ssierrormsg", "ssietag", "ssilastmodified", "ssilegacyexprparser", "ssistarttag", "ssitimeformat", "ssiundefinedecho", "sslcacertificatefile", "sslcacertificatepath", "sslcadnrequestfile", "sslcadnrequestpath", "sslcarevocationcheck", "sslcarevocationfile", "sslcarevocationpath", "sslcertificatechainfile", "sslcertificatefile", "sslcertificatekeyfile", "sslciphersuite", "sslcompression", "sslcryptodevice", "sslengine", "sslfips", "sslhonorcipherorder", "sslinsecurerenegotiation", "sslocspdefaultresponder", "sslocspenable", "sslocspnoverify", "sslocspoverrideresponder", "sslocspproxyurl", "sslocsprespondercertificatefile", "sslocsprespondertimeout", "sslocspresponsemaxage", "sslocspresponsetimeskew", "sslocspuserequestnonce", "sslopensslconfcmd", "ssloptions", "sslpassphrasedialog", "sslprotocol", "sslproxycacertificatefile", "sslproxycacertificatepath", "sslproxycarevocationcheck", "sslproxycarevocationfile", "sslproxycarevocationpath", "sslproxycheckpeercn", "sslproxycheckpeerexpire", "sslproxycheckpeername", "sslproxyciphersuite", "sslproxyengine", "sslproxymachinecertificatechainfile", "sslproxymachinecertificatefile", "sslproxymachinecertificatepath", "sslproxyprotocol", "sslproxyverify", "sslproxyverifydepth", "sslrandomseed", "sslrenegbuffersize", "sslrequire", "sslrequiressl", "sslsessioncache", "sslsessioncachetimeout", "sslsessionticketkeyfile", "sslsessiontickets", "sslsrpunknownuserseed", "sslsrpverifierfile", "sslstaplingcache", "sslstaplingerrorcachetimeout", "sslstaplingfaketrylater", "sslstaplingforceurl", "sslstaplingrespondertimeout", "sslstaplingresponsemaxage", "sslstaplingresponsetimeskew", "sslstaplingreturnrespondererrors", "sslstaplingstandardcachetimeout", "sslstrictsnivhostcheck", "sslusername", "sslusestapling", "sslverifyclient", "sslverifydepth", "startservers", "startthreads", "substitute", "substituteinheritbefore", "substitutemaxlinelength", "suexec", "suexecusergroup", "threadlimit", "threadsperchild", "threadstacksize", "timeout", "traceenable", "transferlog", "typesconfig", "undefine", "undefmacro", "unsetenv", "use", "usecanonicalname", "usecanonicalphysicalport", "user", "userdir", "vhostcgimode", "vhostcgiprivs", "vhostgroup", "vhostprivs", "vhostsecure", "vhostuser", "virtualdocumentroot", "virtualdocumentrootip", "virtualscriptalias", "virtualscriptaliasip", "watchdoginterval", "xbithack", "xml2encalias", "xml2encdefault", "xml2startparse"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.sections
|
16
|
+
@sections ||= Set.new ["authnprovideralias", "authzprovideralias", "directory", "directorymatch", "else", "elseif", "files", "filesmatch", "if", "ifdefine", "ifmodule", "ifversion", "limit", "limitexcept", "location", "locationmatch", "macro", "mdomainset", "proxy", "proxymatch", "requireall", "requireany", "requirenone", "virtualhost"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.values
|
20
|
+
@values ||= Set.new ["add", "addaltclass", "addsuffix", "alias", "all", "allow", "allowanyuri", "allownoslash", "always", "and", "any", "ap_auth_internal_per_uri", "api_version", "append", "ascending", "attribute", "auth", "auth-int", "authconfig", "auto", "backend-address", "balancer_name", "balancer_route_changed", "balancer_session_route", "balancer_session_sticky", "balancer_worker_name", "balancer_worker_route", "base", "basedn", "basic", "before", "block", "boolean", "byte", "byteranges", "cache", "cache-hit", "cache-invalidate", "cache-miss", "cache-revalidate", "cgi", "chain", "change", "charset", "circle", "cmd", "conditional-expression", "condpattern", "conn", "conn_remote_addr", "cookie", "cookie2", "current-uri", "date", "date_gmt", "date_local", "db", "dbm", "decoding", "default", "deny", "descending", "description", "descriptionwidth", "digest", "disabled", "disableenv", "dns", "document_args", "document_name", "document_root", "document_uri", "domain", "double", "duration", "early", "echo", "echomsg", "edit", "edit*", "email", "enableenv", "encoding", "env", "environment-variable-name", "errmsg", "error", "errorlog", "errorlogformat", "execcgi", "expr", "fallback", "fancyindexing", "fast", "file", "file-group", "file-owner", "fileinfo", "filename", "filter", "filter-name", "filter_name", "filters", "finding", "first-dot", "foldersfirst", "followsymlinks", "forever", "form", "formatted", "fpm", "from", "ftype", "full", "function_name", "gdbm", "generic", "gone", "handlers", "hit", "hook_function_name", "host", "hostname", "hse_append_log_parameter", "hse_req_done_with_session", "hse_req_is_connected", "hse_req_is_keep_conn", "hse_req_map_url_to_path", "hse_req_send_response_header", "hse_req_send_response_header_ex", "hse_req_send_url", "hse_req_send_url_redirect_resp", "html", "htmltable", "https", "iconheight", "iconsarelinks", "iconwidth", "ignore", "ignorecase", "ignoreclient", "ignorecontextinfo", "ignoreinherit", "imal", "in", "includes", "includesnoexec", "indexes", "inherit", "inheritbefore", "inheritdown", "inheritdownbefore", "inode", "input", "int", "integer", "intype", "ipaddr", "is_subreq", "iserror", "last-dot", "last_modified", "ldap", "leaf", "legacyprefixdocroot", "level", "limit", "log_function_name", "major", "manual", "map", "map1", "map2", "max", "md5", "md5-sess", "menu", "merge", "mergebase", "minor", "miss", "mod_cache_disk", "mod_cache_socache", "mode", "mtime", "multiviews", "mutual-failure", "mysql", "name", "namewidth", "ndbm", "negotiatedonly", "never", "no", "nochange", "nocontent", "nodecode", "none", "nonfatal", "note", "number-of-ranges", "odbc", "off", "on", "once", "onerror", "onfail", "option", "optional", "options", "or", "oracle", "order", "original-uri", "os", "output", "outtype", "parent-first", "parent-last", "path", "path_info", "permanent", "pipe", "point", "poly", "postgresql", "prefer", "preservescontentlength", "prg", "protocol", "provider-name", "provider_name", "proxy", "proxy-chain-auth", "proxy-fcgi-pathinfo", "proxy-initial-not-pooled", "proxy-interim-response", "proxy-nokeepalive", "proxy-scgi-pathinfo", "proxy-sendcl", "proxy-sendextracrlf", "proxy-source-port", "proxy-status", "qs", "query_string_unescaped", "range", "ratio", "rect", "referer", "regex", "registry", "registry-strict", "remote_addr", "remote_host", "remote_ident", "remote_user", "remove", "request", "request_filename", "request_rec", "request_scheme", "request_uri", "reset", "revalidate", "rewritecond", "rfc2109", "rnd", "scanhtmltitles", "scope", "script", "sdbm", "searching", "secure", "seeother", "selective", "semiformatted", "server", "server_addr", "server_admin", "server_name", "set", "setifempty", "showforbidden", "size", "sizefmt", "sqlite2", "sqlite3", "ssl", "ssl-access-forbidden", "ssl-secure-reneg", "startbody", "stat", "string", "string1", "subnet", "suppresscolumnsorting", "suppressdescription", "suppresshtmlpreamble", "suppressicon", "suppresslastmodified", "suppressrules", "suppresssize", "symlinksifownermatch", "temp", "temporary", "test_condition1", "the_request", "thread", "timefmt", "tls", "to-pattern", "trackmodified", "transform", "txt", "type", "uctonly", "uid", "unescape", "unformatted", "unlimited", "unset", "uri-pattern", "url", "url-of-terms-of-service", "url-path", "useolddateformat", "value", "value-expression", "var", "versionsort", "virtual", "x-forwarded-for", "x-forwarded-host", "x-forwarded-server", "xhtml"]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -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
|
@@ -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
|
data/lib/rouge/lexers/cmake.rb
CHANGED
@@ -49,33 +49,54 @@ module Rouge
|
|
49
49
|
|
50
50
|
id = /[$a-zA-Z_][a-zA-Z0-9_]*/
|
51
51
|
|
52
|
-
state :
|
53
|
-
rule %r/\s+/m, Text
|
52
|
+
state :comments do
|
54
53
|
rule %r/###[^#].*?###/m, Comment::Multiline
|
55
54
|
rule %r/#.*$/, Comment::Single
|
56
55
|
end
|
57
56
|
|
58
|
-
state :
|
59
|
-
|
60
|
-
|
61
|
-
mixin :has_interpolation
|
62
|
-
mixin :comments_and_whitespace
|
57
|
+
state :whitespace do
|
58
|
+
rule %r/\s+/m, Text
|
59
|
+
end
|
63
60
|
|
64
|
-
|
65
|
-
rule %r(
|
66
|
-
rule %r(
|
61
|
+
state :regex_comment do
|
62
|
+
rule %r/^#(?!\{).*$/, Comment::Single
|
63
|
+
rule %r/(\s+)(#(?!\{).*)$/ do
|
64
|
+
groups Text, Comment::Single
|
65
|
+
end
|
67
66
|
end
|
68
67
|
|
69
|
-
state :
|
70
|
-
mixin :comments_and_whitespace
|
68
|
+
state :multiline_regex_begin do
|
71
69
|
rule %r(///) do
|
72
70
|
token Str::Regex
|
73
71
|
goto :multiline_regex
|
74
72
|
end
|
73
|
+
end
|
74
|
+
|
75
|
+
state :multiline_regex_end do
|
76
|
+
rule %r(///([gimy]+\b|\B)), Str::Regex, :pop!
|
77
|
+
end
|
78
|
+
|
79
|
+
state :multiline_regex do
|
80
|
+
mixin :multiline_regex_end
|
81
|
+
mixin :regex_comment
|
82
|
+
mixin :has_interpolation
|
83
|
+
mixin :comments
|
84
|
+
mixin :whitespace
|
85
|
+
mixin :code_escape
|
86
|
+
|
87
|
+
rule %r/\\\D/, Str::Escape
|
88
|
+
rule %r/\\\d+/, Name::Variable
|
89
|
+
rule %r/./m, Str::Regex
|
90
|
+
end
|
91
|
+
|
92
|
+
state :slash_starts_regex do
|
93
|
+
mixin :comments
|
94
|
+
mixin :whitespace
|
95
|
+
mixin :multiline_regex_begin
|
75
96
|
|
76
97
|
rule %r(
|
77
98
|
/(\\.|[^\[/\\\n]|\[(\\.|[^\]\\\n])*\])+/ # a regex
|
78
|
-
([
|
99
|
+
([gimy]+\b|\B)
|
79
100
|
)x, Str::Regex, :pop!
|
80
101
|
|
81
102
|
rule(//) { pop! }
|
@@ -83,7 +104,9 @@ module Rouge
|
|
83
104
|
|
84
105
|
state :root do
|
85
106
|
rule(%r(^(?=\s|/|<!--))) { push :slash_starts_regex }
|
86
|
-
mixin :
|
107
|
+
mixin :comments
|
108
|
+
mixin :whitespace
|
109
|
+
|
87
110
|
rule %r(
|
88
111
|
[+][+]|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\bin\b|\bof\b|
|
89
112
|
[?]|:|=|[|][|]|\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&|^/])=?
|
@@ -129,10 +152,19 @@ module Rouge
|
|
129
152
|
rule %r/'/, Str, :sqs
|
130
153
|
end
|
131
154
|
|
155
|
+
state :code_escape do
|
156
|
+
rule %r(\\(
|
157
|
+
c[A-Z]|
|
158
|
+
x[0-9a-fA-F]{2}|
|
159
|
+
u[0-9a-fA-F]{4}|
|
160
|
+
u\{[0-9a-fA-F]{4}\}
|
161
|
+
))x, Str::Escape
|
162
|
+
end
|
163
|
+
|
132
164
|
state :strings do
|
133
165
|
# all coffeescript strings are multi-line
|
134
166
|
rule %r/[^#\\'"]+/m, Str
|
135
|
-
|
167
|
+
mixin :code_escape
|
136
168
|
rule %r/\\./, Str::Escape
|
137
169
|
rule %r/#/, Str
|
138
170
|
end
|