rouge 3.17.0 → 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +65 -51
  3. data/lib/rouge/demos/cypher +5 -0
  4. data/lib/rouge/demos/datastudio +21 -0
  5. data/lib/rouge/demos/ghc-cmm +23 -0
  6. data/lib/rouge/demos/isbl +4 -0
  7. data/lib/rouge/demos/rego +8 -0
  8. data/lib/rouge/demos/solidity +13 -0
  9. data/lib/rouge/demos/yang +17 -0
  10. data/lib/rouge/lexer.rb +2 -1
  11. data/lib/rouge/lexers/apache.rb +4 -8
  12. data/lib/rouge/lexers/apache/keywords.rb +15 -0
  13. data/lib/rouge/lexers/cmake.rb +1 -0
  14. data/lib/rouge/lexers/console.rb +53 -37
  15. data/lib/rouge/lexers/cpp.rb +12 -5
  16. data/lib/rouge/lexers/cypher.rb +108 -0
  17. data/lib/rouge/lexers/datastudio.rb +138 -0
  18. data/lib/rouge/lexers/fsharp.rb +1 -0
  19. data/lib/rouge/lexers/ghc_cmm.rb +340 -0
  20. data/lib/rouge/lexers/gherkin.rb +1 -1
  21. data/lib/rouge/lexers/isbl.rb +97 -0
  22. data/lib/rouge/lexers/isbl/builtins.rb +17 -0
  23. data/lib/rouge/lexers/json.rb +3 -0
  24. data/lib/rouge/lexers/json_doc.rb +1 -0
  25. data/lib/rouge/lexers/kotlin.rb +4 -0
  26. data/lib/rouge/lexers/lasso.rb +4 -9
  27. data/lib/rouge/lexers/lasso/keywords.rb +14 -0
  28. data/lib/rouge/lexers/lua.rb +1 -1
  29. data/lib/rouge/lexers/markdown.rb +1 -1
  30. data/lib/rouge/lexers/mathematica.rb +1 -1
  31. data/lib/rouge/lexers/matlab.rb +3 -4
  32. data/lib/rouge/lexers/matlab/builtins.rb +11 -0
  33. data/lib/rouge/lexers/pascal.rb +1 -1
  34. data/lib/rouge/lexers/php.rb +47 -32
  35. data/lib/rouge/lexers/python.rb +66 -57
  36. data/lib/rouge/lexers/racket.rb +24 -1
  37. data/lib/rouge/lexers/rego.rb +45 -0
  38. data/lib/rouge/lexers/ruby.rb +11 -1
  39. data/lib/rouge/lexers/solidity.rb +185 -0
  40. data/lib/rouge/lexers/sqf.rb +1 -1
  41. data/lib/rouge/lexers/terraform.rb +15 -0
  42. data/lib/rouge/lexers/typescript.rb +4 -0
  43. data/lib/rouge/lexers/viml.rb +1 -1
  44. data/lib/rouge/lexers/vue.rb +4 -1
  45. data/lib/rouge/lexers/yang.rb +147 -0
  46. data/lib/rouge/version.rb +1 -1
  47. metadata +20 -5
  48. data/lib/rouge/lexers/apache/keywords.yml +0 -764
  49. data/lib/rouge/lexers/lasso/keywords.yml +0 -446
  50. data/lib/rouge/lexers/matlab/builtins.yml +0 -3515
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1353759e9c75e7413608191e1fc9f670c4ac4f9db4cb3bc82c9c64d11ae54470
4
- data.tar.gz: ae8d26b4295c1089d10c6567c3c5796613be6222e5dd22553f5f62fc238b2765
3
+ metadata.gz: 579264110ed9ae2f82195af1d9d83d2ebf6288f8ce3cd6909c2a9d563ae0e1d5
4
+ data.tar.gz: 25a1809f05ec5aab6f04ee7b885a17cf8b1388e1247284e773bc166d13a9e296
5
5
  SHA512:
6
- metadata.gz: ed188bc8fafde40a70384fc5bfb63a179ad23f4bab7c2616811e8260641b7a16fc2843b78c49543a4c45b8f790e47f68508f4979c9a10155ba4de94756c49382
7
- data.tar.gz: f88c70213003b8235e275cca3d3776bb48abca5bd6cfdc52f7ef6ef398195028b7201b07c020ebaf5f509683cc7785a2bf93c6e0527a4c51a77f1ef8ca5eece9
6
+ metadata.gz: 832c13a7236b814d53a5a6b170fc00b4961efb2cdee91053bfc3a6386a9bc6c7b071f9fa51606321e94249b57c6f549f6e4bb420e7647ab68ca6a3c6e49d8c63
7
+ data.tar.gz: 5889f29c2788788120fd698ec004b847c5bafb7df0b22af36c9f1d2a78218c81e7fd136b359b586ed8f586e0a65eceb156721efcb95d95e3af7df34d0b174038
@@ -6,6 +6,10 @@ require 'pathname'
6
6
 
7
7
  # The containing module for Rouge
8
8
  module Rouge
9
+ # cache value in a constant since `__dir__` allocates a new string
10
+ # on every call.
11
+ LIB_DIR = __dir__.freeze
12
+
9
13
  class << self
10
14
  def reload!
11
15
  Object.send :remove_const, :Rouge
@@ -31,63 +35,73 @@ module Rouge
31
35
 
32
36
  formatter.format(lexer.lex(text), &b)
33
37
  end
34
- end
35
- end
36
38
 
37
- # mimic Kernel#require_relative API
38
- def load_relative(path)
39
- load File.join(__dir__, "#{path}.rb")
40
- end
39
+ # Load a file relative to the `lib/rouge` path.
40
+ #
41
+ # @api private
42
+ def load_file(path)
43
+ load File.join(LIB_DIR, "rouge/#{path}.rb")
44
+ end
41
45
 
42
- def lexer_dir(path = '')
43
- File.join(__dir__, 'rouge', 'lexers', path)
46
+ # Load the lexers in the `lib/rouge/lexers` directory.
47
+ #
48
+ # @api private
49
+ def load_lexers
50
+ # The trailing slash is necessary to avoid lexers being loaded multiple
51
+ # times by `Lexers.load_lexer`
52
+ lexer_dir = File.join(LIB_DIR, "rouge/lexers/")
53
+ Dir.glob(File.join(lexer_dir, '*.rb')).each do |f|
54
+ Lexers.load_lexer(f.sub(lexer_dir, ''))
55
+ end
56
+ end
57
+ end
44
58
  end
45
59
 
46
- load_relative 'rouge/version'
47
- load_relative 'rouge/util'
48
- load_relative 'rouge/text_analyzer'
49
- load_relative 'rouge/token'
60
+ Rouge.load_file 'version'
61
+ Rouge.load_file 'util'
62
+ Rouge.load_file 'text_analyzer'
63
+ Rouge.load_file 'token'
50
64
 
51
- load_relative 'rouge/lexer'
52
- load_relative 'rouge/regex_lexer'
53
- load_relative 'rouge/template_lexer'
65
+ Rouge.load_file 'lexer'
66
+ Rouge.load_file 'regex_lexer'
67
+ Rouge.load_file 'template_lexer'
54
68
 
55
- Dir.glob(lexer_dir('*rb')).each { |f| Rouge::Lexers.load_lexer(f.sub(lexer_dir, '')) }
69
+ Rouge.load_lexers
56
70
 
57
- load_relative 'rouge/guesser'
58
- load_relative 'rouge/guessers/util'
59
- load_relative 'rouge/guessers/glob_mapping'
60
- load_relative 'rouge/guessers/modeline'
61
- load_relative 'rouge/guessers/filename'
62
- load_relative 'rouge/guessers/mimetype'
63
- load_relative 'rouge/guessers/source'
64
- load_relative 'rouge/guessers/disambiguation'
71
+ Rouge.load_file 'guesser'
72
+ Rouge.load_file 'guessers/util'
73
+ Rouge.load_file 'guessers/glob_mapping'
74
+ Rouge.load_file 'guessers/modeline'
75
+ Rouge.load_file 'guessers/filename'
76
+ Rouge.load_file 'guessers/mimetype'
77
+ Rouge.load_file 'guessers/source'
78
+ Rouge.load_file 'guessers/disambiguation'
65
79
 
66
- load_relative 'rouge/formatter'
67
- load_relative 'rouge/formatters/html'
68
- load_relative 'rouge/formatters/html_table'
69
- load_relative 'rouge/formatters/html_pygments'
70
- load_relative 'rouge/formatters/html_legacy'
71
- load_relative 'rouge/formatters/html_linewise'
72
- load_relative 'rouge/formatters/html_line_table'
73
- load_relative 'rouge/formatters/html_inline'
74
- load_relative 'rouge/formatters/terminal256'
75
- load_relative 'rouge/formatters/terminal_truecolor'
76
- load_relative 'rouge/formatters/tex'
77
- load_relative 'rouge/formatters/null'
80
+ Rouge.load_file 'formatter'
81
+ Rouge.load_file 'formatters/html'
82
+ Rouge.load_file 'formatters/html_table'
83
+ Rouge.load_file 'formatters/html_pygments'
84
+ Rouge.load_file 'formatters/html_legacy'
85
+ Rouge.load_file 'formatters/html_linewise'
86
+ Rouge.load_file 'formatters/html_line_table'
87
+ Rouge.load_file 'formatters/html_inline'
88
+ Rouge.load_file 'formatters/terminal256'
89
+ Rouge.load_file 'formatters/terminal_truecolor'
90
+ Rouge.load_file 'formatters/tex'
91
+ Rouge.load_file 'formatters/null'
78
92
 
79
- load_relative 'rouge/theme'
80
- load_relative 'rouge/tex_theme_renderer'
81
- load_relative 'rouge/themes/thankful_eyes'
82
- load_relative 'rouge/themes/colorful'
83
- load_relative 'rouge/themes/base16'
84
- load_relative 'rouge/themes/github'
85
- load_relative 'rouge/themes/igor_pro'
86
- load_relative 'rouge/themes/monokai'
87
- load_relative 'rouge/themes/molokai'
88
- load_relative 'rouge/themes/monokai_sublime'
89
- load_relative 'rouge/themes/gruvbox'
90
- load_relative 'rouge/themes/tulip'
91
- load_relative 'rouge/themes/pastie'
92
- load_relative 'rouge/themes/bw'
93
- load_relative 'rouge/themes/magritte'
93
+ Rouge.load_file 'theme'
94
+ Rouge.load_file 'tex_theme_renderer'
95
+ Rouge.load_file 'themes/thankful_eyes'
96
+ Rouge.load_file 'themes/colorful'
97
+ Rouge.load_file 'themes/base16'
98
+ Rouge.load_file 'themes/github'
99
+ Rouge.load_file 'themes/igor_pro'
100
+ Rouge.load_file 'themes/monokai'
101
+ Rouge.load_file 'themes/molokai'
102
+ Rouge.load_file 'themes/monokai_sublime'
103
+ Rouge.load_file 'themes/gruvbox'
104
+ Rouge.load_file 'themes/tulip'
105
+ Rouge.load_file 'themes/pastie'
106
+ Rouge.load_file 'themes/bw'
107
+ Rouge.load_file 'themes/magritte'
@@ -0,0 +1,5 @@
1
+ // Cypher Mode for Rouge
2
+ CREATE (john:Person {name: 'John'})
3
+ MATCH (user)-[:friend]->(follower)
4
+ WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ 'S.*'
5
+ RETURN user.name, follower.name
@@ -0,0 +1,21 @@
1
+
2
+ Get_Variable("EUSER","ENV","USERNAME");
3
+
4
+ Message("Le Login Windows est : %EUSER%");
5
+
6
+ Get_Variable("st","JOB","FOLDER1.date_err.SYSTEM.STATUS");
7
+
8
+
9
+ AFFECT("filter1", '%%/"t"');
10
+ AFFECT("filter2", '%%/"pi"');
11
+ JSONTOSQL("%{jsonpath}%/file.json", "",
12
+ " JSONPATH like '%filter1%' ", "a = JSONVALUE",
13
+ " JSONPATH like '%filter2%' ", "b = JSONVALUE; output(json_data, a, b)");
14
+
15
+
16
+ Affect(VAR1,'%TEST%'); //Créer et affecter la variable VAR1 avec une chaîne
17
+ select * from TABLE1 where COL1 like %VAR1%; //utiliser la variable VAR1 dans une requête
18
+
19
+ select * from TEST_TABLE; //exécution d'une requête Select pour ramener des valeurs
20
+ Affect_LastColumns("TEST1"); //création du paramètre TEST1
21
+
@@ -0,0 +1,23 @@
1
+ [lvl_s4t3_entry() // [R1]
2
+ { info_tbls: [(c4uB,
3
+ label: lvl_s4t3_info
4
+ rep: HeapRep 1 ptrs { Thunk }
5
+ srt: Nothing)]
6
+ stack_info: arg_space: 8 updfr_space: Just 8
7
+ }
8
+ {offset
9
+ c4uB: // global
10
+ if ((Sp + -32) < SpLim) (likely: False) goto c4uC; else goto c4uD;
11
+ c4uC: // global
12
+ R1 = R1;
13
+ call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8;
14
+ c4uD: // global
15
+ I64[Sp - 16] = stg_upd_frame_info;
16
+ P64[Sp - 8] = R1;
17
+ R2 = P64[R1 + 16];
18
+ I64[Sp - 32] = stg_ap_p_info;
19
+ P64[Sp - 24] = Main.fib3_closure+1;
20
+ Sp = Sp - 32;
21
+ call GHC.Num.fromInteger_info(R2) args: 40, res: 0, upd: 24;
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ NameReq = Object.Requisites(SYSREQ_NAME)
2
+ if Assigned(NameReq.AsString)
3
+ ShowMessage("Привет мир")
4
+ endif
@@ -0,0 +1,8 @@
1
+ package httpapi.authz
2
+
3
+ subordinates = {"alice": [], "charlie": [], "bob": ["alice"], "betty": ["charlie"]}
4
+
5
+ # HTTP API request
6
+ import input
7
+
8
+ default allow = false
@@ -0,0 +1,13 @@
1
+ pragma solidity ~0.4.15;
2
+
3
+ interface IMirror {
4
+ function reflect() external payable returns(bool /* ain't I pretty?.. */);
5
+ }
6
+
7
+ contract Mirror is IMirror {
8
+ event logMessage(address indexed sender, uint256 value, uint256 gas, bytes data);
9
+
10
+ function () { // no funny stuff
11
+ revert();
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ module petstore {
2
+ namespace "http://autlan.dt/gribok/yang/example";
3
+ prefix ex;
4
+
5
+ revision 2020-04-01 {
6
+ description "Example yang";
7
+ }
8
+
9
+ container pets {
10
+ list dogs {
11
+ key name;
12
+ leaf name {
13
+ type string;
14
+ }
15
+ }
16
+ }
17
+ }
@@ -505,12 +505,13 @@ module Rouge
505
505
  end
506
506
 
507
507
  module Lexers
508
+ BASE_DIR = "#{__dir__}/lexers".freeze
508
509
  @_loaded_lexers = {}
509
510
 
510
511
  def self.load_lexer(relpath)
511
512
  return if @_loaded_lexers.key?(relpath)
512
513
  @_loaded_lexers[relpath] = true
513
- load File.join(__dir__, 'lexers', relpath)
514
+ load File.join(BASE_DIR, relpath)
514
515
  end
515
516
  end
516
517
  end
@@ -11,14 +11,10 @@ module Rouge
11
11
  mimetypes 'text/x-httpd-conf', 'text/x-apache-conf'
12
12
  filenames '.htaccess', 'httpd.conf'
13
13
 
14
- class << self
15
- attr_reader :keywords
16
- end
17
- # Load Apache keywords from separate YML file
18
- @keywords = ::YAML.load_file(File.join(__dir__, 'apache/keywords.yml')).tap do |h|
19
- h.each do |k,v|
20
- h[k] = Set.new v
21
- end
14
+ # self-modifying method that loads the keywords file
15
+ def self.keywords
16
+ load File.join(Lexers::BASE_DIR, 'apache/keywords.rb')
17
+ keywords
22
18
  end
23
19
 
24
20
  def name_for_token(token, kwtype, tktype)
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ # automatically generated by `rake builtins:apache`
5
+ module Rouge
6
+ module Lexers
7
+ def Apache.keywords
8
+ @keywords ||= {}.tap do |h|
9
+ h[:sections] = Set.new ["directory", "directorymatch", "files", "filesmatch", "ifdefine", "ifmodule", "limit", "limitexcept", "location", "locationmatch", "proxy", "proxymatch", "virtualhost"]
10
+ h[:directives] = Set.new ["acceptfilter", "acceptmutex", "acceptpathinfo", "accessconfig", "accessfilename", "action", "addalt", "addaltbyencoding", "addaltbytype", "addcharset", "adddefaultcharset", "adddescription", "addencoding", "addhandler", "addicon", "addiconbyencoding", "addiconbytype", "addinputfilter", "addlanguage", "addmodule", "addmoduleinfo", "addoutputfilter", "addoutputfilterbytype", "addtype", "agentlog", "alias", "aliasmatch", "allow", "allowconnect", "allowencodedslashes", "allowmethods", "allowoverride", "allowoverridelist", "anonymous", "anonymous_authoritative", "anonymous_logemail", "anonymous_mustgiveemail", "anonymous_nouserid", "anonymous_verifyemail", "assignuserid", "authauthoritative", "authdbauthoritative", "authdbgroupfile", "authdbmauthoritative", "asyncrequestworkerfactor", "authbasicauthoritative", "authbasicfake", "authbasicprovider", "authbasicusedigestalgorithm", "authdbduserpwquery", "authdbduserrealmquery", "authdbmgroupfile", "authdbmtype", "authdbmuserfile", "authdbuserfile", "authdigestalgorithm", "authdigestdomain", "authdigestfile", "authdigestgroupfile", "authdigestnccheck", "authdigestnonceformat", "authdigestnoncelifetime", "authdigestprovider", "authdigestqop", "authdigestshmemsize", "authformauthoritative", "authformbody", "authformdisablenostore", "authformfakebasicauth", "authformlocation", "authformloginrequiredlocation", "authformloginsuccesslocation", "authformlogoutlocation", "authformmethod", "authformmimetype", "authformpassword", "authformprovider", "authformsitepassphrase", "authformsize", "authformusername", "authgroupfile", "authldapauthoritative", "authldapauthorizeprefix", "authldapbindauthoritative", "authldapbinddn", "authldapbindpassword", "authldapcharsetconfig", "authldapcompareasuser", "authldapcomparednonserver", "authldapdereferencealiases", "authldapenabled", "authldapfrontpagehack", "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", "bindaddress", "browsermatch", "browsermatchnocase", "bs2000account", "bufferedlogs", "buffersize", "cachedefaultexpire", "cachedetailheader", "cachedirlength", "cachedirlevels", "cachedisable", "cacheenable", "cacheexpirycheck", "cachefile", "cacheforcecompletion", "cachegcclean", "cachegcdaily", "cachegcinterval", "cachegcmemusage", "cachegcunused", "cacheheader", "cacheignorecachecontrol", "cacheignoreheaders", "cacheignorenolastmod", "cacheignorequerystring", "cacheignoreurlsessionidentifiers", "cachekeybaseurl", "cachelastmodifiedfactor", "cachelock", "cachelockmaxage", "cachelockpath", "cachemaxexpire", "cachemaxfilesize", "cacheminexpire", "cacheminfilesize", "cachenegotiateddocs", "cachequickhandler", "cachereadsize", "cachereadtime", "cacheroot", "cachesize", "cachetimemargin", "cachesocache", "cachesocachemaxsize", "cachesocachemaxtime", "cachesocachemintime", "cachesocachereadsize", "cachesocachereadtime", "cachestaleonerror", "cachestoreexpired", "cachestorenostore", "cachestoreprivate", "cgidscripttimeout", "cgimapextension", "cgipassauth", "charsetdefault", "charsetoptions", "charsetsourceenc", "checkcaseonly", "checkspelling", "childperuserid", "clearmodulelist", "chrootdir", "contentdigest", "cookiedomain", "cookieexpires", "cookielog", "cookiename", "cookiestyle", "cookietracking", "coredumpdirectory", "customlog", "dav", "davdepthinfinity", "davgenericlockdb", "davlockdb", "davmintimeout", "dbdexptime", "dbdinitsql", "dbdkeep", "dbdmax", "dbdmin", "dbdparams", "dbdpersist", "dbdpreparesql", "dbdriver", "defaulticon", "defaultlanguage", "defaultmode", "defaultruntimedir", "defaulttype", "define", "deflatebuffersize", "deflatecompressionlevel", "deflatefilternote", "deflateinflatelimitrequestbody", "deflateinflateratioburst", "deflateinflateratiolimit", "deflatememlevel", "deflatewindowsize", "deny", "directorycheckhandler", "directoryindex", "directoryindexredirect", "directoryslash", "doctitle", "doctrailer", "documentroot", "dtraceprivileges", "dumpioinput", "dumpiooutput", "enableexceptionhook", "enablemmap", "enablesendfile", "error", "errordocument", "errorlog", "errorlogformat", "example", "expiresactive", "expiresbytype", "expiresdefault", "extendedstatus", "extfilterdefine", "extfilteroptions", "fallbackresource", "fancyindexing", "fileetag", "filterchain", "filterdeclare", "filterprotocol", "filterprovider", "filtertrace", "forcelanguagepriority", "forcetype", "forensiclog", "globallog", "gprofdir", "gracefulshutdowntimeout", "group", "h2direct", "h2keepalivetimeout", "h2maxsessionstreams", "h2maxworkeridleseconds", "h2maxworkers", "h2minworkers", "h2moderntlsonly", "h2push", "h2pushdiarysize", "h2pushpriority", "h2serializeheaders", "h2sessionextrafiles", "h2streammaxmemsize", "h2streamtimeout", "h2timeout", "h2tlscooldownsecs", "h2tlswarmupsize", "h2upgrade", "h2windowsize", "header", "headername", "headprefix", "headsuffix", "hidesys", "hideurl", "heartbeataddress", "heartbeatlisten", "heartbeatmaxservers", "heartbeatstorage", "heartbeatstorage", "hostnamelookups", "htmldir", "httplogfile", "identitycheck", "identitychecktimeout", "imapbase", "imapdefault", "imapmenu", "include", "includeoptional", "indexheadinsert", "indexignore", "indexignorereset", "indexoptions", "indexorderdefault", "indexstylesheet", "inputsed", "isapiappendlogtoerrors", "isapiappendlogtoquery", "isapicachefile", "isapifakeasync", "isapilognotsupported", "isapireadaheadbuffer", "keepalive", "keepalivetimeout", "keptbodysize", "languagepriority", "lasturls", "ldapcacheentries", "ldapcachettl", "ldapconnectionpoolttl", "ldapconnectiontimeout", "ldaplibrarydebug", "ldapopcacheentries", "ldapopcachettl", "ldapreferralhoplimit", "ldapreferrals", "ldapretries", "ldapretrydelay", "ldapsharedcachefile", "ldapsharedcachesize", "ldaptimeout", "ldaptrustedca", "ldaptrustedcatype", "ldaptrustedclientcert", "ldaptrustedglobalcert", "ldaptrustedmode", "ldapverifyservercert", "limitinternalrecursion", "limitrequestbody", "limitrequestfields", "limitrequestfieldsize", "limitrequestline", "limitxmlrequestbody", "listen", "listenbacklog", "listencoresbucketsratio", "loadfile", "loadmodule", "lockfile", "logformat", "logiotrackttfb", "loglevel", "logmessage", "luaauthzprovider", "luacodecache", "luahookaccesschecker", "luahookauthchecker", "luahookcheckuserid", "luahookfixups", "luahookinsertfilter", "luahooklog", "luahookmaptostorage", "luahooktranslatename", "luahooktypechecker", "luainherit", "luainputfilter", "luamaphandler", "luaoutputfilter", "luapackagecpath", "luapackagepath", "luaquickhandler", "luaroot", "luascope", "maxclients", "maxconnectionsperchild", "maxkeepaliverequests", "maxmemfree", "maxrequestsperchild", "maxrequestsperthread", "maxrangeoverlaps", "maxrangereversals", "maxranges", "maxrequestworkers", "maxspareservers", "maxsparethreads", "maxthreads", "maxthreadsperchild", "mcachemaxobjectcount", "mcachemaxobjectsize", "mcachemaxstreamingbuffer", "mcacheminobjectsize", "mcacheremovalalgorithm", "mcachesize", "memcacheconnttl", "mergetrailers", "metadir", "metafiles", "metasuffix", "mimemagicfile", "minspareservers", "minsparethreads", "mmapfile", "modemstandard", "modmimeusepathinfo", "multiviewsmatch", "mutex", "namevirtualhost", "nocache", "noproxy", "numservers", "nwssltrustedcerts", "nwsslupgradeable", "options", "order", "outputsed", "passenv", "pidfile", "port", "privatedir", "privilegesmode", "protocol", "protocolecho", "protocols", "protocolshonororder", "proxyaddheaders", "proxybadheader", "proxyblock", "proxydomain", "proxyerroroverride", "proxyexpressdbmfile", "proxyexpressdbmtype", "proxyexpressenable", "proxyftpdircharset", "proxyftpescapewildcards", "proxyftplistonwildcard", "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", "refererignore", "refererlog", "reflectorheader", "remoteipheader", "remoteipinternalproxy", "remoteipinternalproxylist", "remoteipproxiesheader", "remoteiptrustedproxy", "remoteiptrustedproxylist", "removecharset", "removeencoding", "removehandler", "removeinputfilter", "removelanguage", "removeoutputfilter", "removetype", "requestheader", "requestreadtimeout", "require", "resourceconfig", "rewritebase", "rewritecond", "rewriteengine", "rewritelock", "rewritelog", "rewriteloglevel", "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", "servertype", "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", "sslmutex", "sslocspdefaultresponder", "sslocspenable", "sslocspoverrideresponder", "sslocspproxyurl", "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", "topsites", "topurls", "traceenable", "transferlog", "typesconfig", "undefine", "undefmacro", "unsetenv", "use", "usecanonicalname", "usecanonicalphysicalport", "user", "userdir", "vhostcgimode", "vhostcgiprivs", "vhostgroup", "vhostprivs", "vhostsecure", "vhostuser", "virtualdocumentroot", "virtualdocumentrootip", "virtualscriptalias", "virtualscriptaliasip", "win32disableacceptex", "watchdoginterval", "xbithack", "xml2encalias", "xml2encdefault", "xml2startparse"]
11
+ h[:values] = Set.new ["add", "All", "allow", "any", "append", "AuthConfig", "Basic", "CONNECT", "DELETE", "deny", "Digest", "double", "downgrade-1.0", "email", "env", "error", "ExecCGI", "FancyIndexing", "FileInfo", "FollowSymLinks", "force-response-1.0", "formatted", "from", "full", "Full", "GET", "gone", "group", "IconsAreLinks", "Includes", "IncludesNOEXEC", "Indexes", "inetd", "inherit", "Limit", "map", "Minimal", "MultiViews", "mutual-failure", "nocontent", "nokeepalive", "none", "None", "off", "on", "Options", "OPTIONS", "OS", "permanent", "POST", "PUT", "referer", "ScanHTMLTitles", "seeother", "semi-formatted", "set", "standalone", "SuppressDescription", "SuppressLastModified", "SuppressSize", "SymLinksIfOwnerMatch", "temporary", "unformatted", "unset", "URL", "user", "valid-user"]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -164,6 +164,7 @@ module Rouge
164
164
  goto :bracket_string
165
165
  end
166
166
 
167
+ rule %r/\\"/, Text
167
168
  rule %r/"/, Str::Double, :quoted_argument
168
169
 
169
170
  rule %r/([A-Za-z_][A-Za-z0-9_]*)(#{SPACE}*)(\()/ do |m|
@@ -9,12 +9,14 @@ module Rouge
9
9
  # line before passing the remainder of the line to the language lexer for
10
10
  # the shell (by default, the {Shell} lexer).
11
11
  #
12
- # The {ConsoleLexer} class accepts four options:
12
+ # The {ConsoleLexer} class accepts five options:
13
13
  # 1. **lang**: the shell language to lex (default: `shell`);
14
14
  # 2. **output**: the output language (default: `plaintext?token=Generic.Output`);
15
15
  # 3. **prompt**: comma-separated list of strings that indicate the end of a
16
16
  # prompt (default: `$,#,>,;`);
17
17
  # 4. **comments**: whether to enable comments.
18
+ # 5. **error**: comma-separated list of strings that indicate the start of an
19
+ # error message
18
20
  #
19
21
  # The comments option, if enabled, will lex lines that begin with a `#` as a
20
22
  # comment. Please note that this option will only work if the prompt is
@@ -39,12 +41,13 @@ module Rouge
39
41
  tag 'console'
40
42
  aliases 'terminal', 'shell_session', 'shell-session'
41
43
  filenames '*.cap'
42
- desc 'A generic lexer for shell sessions. Accepts ?lang and ?output lexer options, a ?prompt option, and ?comments to enable # comments.'
44
+ desc 'A generic lexer for shell sessions. Accepts ?lang and ?output lexer options, a ?prompt option, ?comments to enable # comments, and ?error to handle error messages.'
43
45
 
44
46
  option :lang, 'the shell language to lex (default: shell)'
45
47
  option :output, 'the output language (default: plaintext?token=Generic.Output)'
46
48
  option :prompt, 'comma-separated list of strings that indicate the end of a prompt. (default: $,#,>,;)'
47
49
  option :comments, 'enable hash-comments at the start of a line - otherwise interpreted as a prompt. (default: false, implied by ?prompt not containing `#`)'
50
+ option :error, 'comma-separated list of strings that indicate the start of an error message'
48
51
 
49
52
  def initialize(*)
50
53
  super
@@ -52,14 +55,24 @@ module Rouge
52
55
  @lang = lexer_option(:lang) { 'shell' }
53
56
  @output = lexer_option(:output) { PlainText.new(token: Generic::Output) }
54
57
  @comments = bool_option(:comments) { :guess }
58
+ @error = list_option(:error) { nil }
55
59
  end
56
60
 
57
- def prompt_regex
58
- @prompt_regex ||= begin
59
- /^#{prompt_prefix_regex}(?:#{end_chars.map(&Regexp.method(:escape)).join('|')})/
61
+ # whether to allow comments. if manually specifying a prompt that isn't
62
+ # simply "#", we flag this to on
63
+ def allow_comments?
64
+ case @comments
65
+ when :guess
66
+ @prompt && !@prompt.empty? && !end_chars.include?('#')
67
+ else
68
+ @comments
60
69
  end
61
70
  end
62
71
 
72
+ def comment_regex
73
+ /\A\s*?#/
74
+ end
75
+
63
76
  def end_chars
64
77
  @end_chars ||= if @prompt.any?
65
78
  @prompt.reject { |c| c.empty? }
@@ -70,22 +83,9 @@ module Rouge
70
83
  end
71
84
  end
72
85
 
73
- # whether to allow comments. if manually specifying a prompt that isn't
74
- # simply "#", we flag this to on
75
- def allow_comments?
76
- case @comments
77
- when :guess
78
- @prompt && !@prompt.empty? && !end_chars.include?('#')
79
- else
80
- @comments
81
- end
82
- end
83
-
84
- def prompt_prefix_regex
85
- if allow_comments?
86
- /[^<#]*?/m
87
- else
88
- /.*?/m
86
+ def error_regex
87
+ @error_regex ||= if @error.any?
88
+ /^(?:#{@error.map(&Regexp.method(:escape)).join('|')})/
89
89
  end
90
90
  end
91
91
 
@@ -102,6 +102,10 @@ module Rouge
102
102
  end
103
103
  end
104
104
 
105
+ def line_regex
106
+ /(\\.|[^\\])*?(\n|$)/m
107
+ end
108
+
105
109
  def output_lexer
106
110
  @output_lexer ||= case @output
107
111
  when nil
@@ -115,22 +119,6 @@ module Rouge
115
119
  end
116
120
  end
117
121
 
118
- def line_regex
119
- /(\\.|[^\\])*?(\n|$)/m
120
- end
121
-
122
- def comment_regex
123
- /\A\s*?#/
124
- end
125
-
126
- def stream_tokens(input, &output)
127
- input = StringScanner.new(input)
128
- lang_lexer.reset!
129
- output_lexer.reset!
130
-
131
- process_line(input, &output) while !input.eos?
132
- end
133
-
134
122
  def process_line(input, &output)
135
123
  input.scan(line_regex)
136
124
 
@@ -162,6 +150,12 @@ module Rouge
162
150
  lang_lexer.reset!
163
151
 
164
152
  yield Comment, input[0]
153
+ elsif error_regex =~ input[0]
154
+ puts "console: matched error #{input[0].inspect}" if @debug
155
+ output_lexer.reset!
156
+ lang_lexer.reset!
157
+
158
+ yield Generic::Error, input[0]
165
159
  else
166
160
  puts "console: matched output #{input[0].inspect}" if @debug
167
161
  lang_lexer.reset!
@@ -169,6 +163,28 @@ module Rouge
169
163
  output_lexer.continue_lex(input[0], &output)
170
164
  end
171
165
  end
166
+
167
+ def prompt_prefix_regex
168
+ if allow_comments?
169
+ /[^<#]*?/m
170
+ else
171
+ /.*?/m
172
+ end
173
+ end
174
+
175
+ def prompt_regex
176
+ @prompt_regex ||= begin
177
+ /^#{prompt_prefix_regex}(?:#{end_chars.map(&Regexp.method(:escape)).join('|')})/
178
+ end
179
+ end
180
+
181
+ def stream_tokens(input, &output)
182
+ input = StringScanner.new(input)
183
+ lang_lexer.reset!
184
+ output_lexer.reset!
185
+
186
+ process_line(input, &output) while !input.eos?
187
+ end
172
188
  end
173
189
  end
174
190
  end