gitlab-rouge 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +23 -0
  3. data/LICENSE +186 -0
  4. data/bin/rougify +16 -0
  5. data/gitlab-rouge.gemspec +17 -0
  6. data/lib/rouge.rb +57 -0
  7. data/lib/rouge/cli.rb +363 -0
  8. data/lib/rouge/demos/apache +21 -0
  9. data/lib/rouge/demos/applescript +2 -0
  10. data/lib/rouge/demos/c +8 -0
  11. data/lib/rouge/demos/clojure +5 -0
  12. data/lib/rouge/demos/coffeescript +5 -0
  13. data/lib/rouge/demos/common_lisp +1 -0
  14. data/lib/rouge/demos/conf +4 -0
  15. data/lib/rouge/demos/cpp +8 -0
  16. data/lib/rouge/demos/csharp +5 -0
  17. data/lib/rouge/demos/css +4 -0
  18. data/lib/rouge/demos/dart +6 -0
  19. data/lib/rouge/demos/diff +7 -0
  20. data/lib/rouge/demos/elixir +1 -0
  21. data/lib/rouge/demos/erb +1 -0
  22. data/lib/rouge/demos/erlang +7 -0
  23. data/lib/rouge/demos/factor +5 -0
  24. data/lib/rouge/demos/gherkin +17 -0
  25. data/lib/rouge/demos/glsl +14 -0
  26. data/lib/rouge/demos/go +7 -0
  27. data/lib/rouge/demos/groovy +9 -0
  28. data/lib/rouge/demos/haml +5 -0
  29. data/lib/rouge/demos/handlebars +7 -0
  30. data/lib/rouge/demos/haskell +6 -0
  31. data/lib/rouge/demos/html +8 -0
  32. data/lib/rouge/demos/http +14 -0
  33. data/lib/rouge/demos/ini +4 -0
  34. data/lib/rouge/demos/io +11 -0
  35. data/lib/rouge/demos/java +5 -0
  36. data/lib/rouge/demos/javascript +1 -0
  37. data/lib/rouge/demos/json +1 -0
  38. data/lib/rouge/demos/json-doc +1 -0
  39. data/lib/rouge/demos/liquid +11 -0
  40. data/lib/rouge/demos/literate_coffeescript +3 -0
  41. data/lib/rouge/demos/literate_haskell +7 -0
  42. data/lib/rouge/demos/llvm +20 -0
  43. data/lib/rouge/demos/lua +12 -0
  44. data/lib/rouge/demos/make +6 -0
  45. data/lib/rouge/demos/markdown +4 -0
  46. data/lib/rouge/demos/matlab +6 -0
  47. data/lib/rouge/demos/moonscript +16 -0
  48. data/lib/rouge/demos/nginx +5 -0
  49. data/lib/rouge/demos/nim +27 -0
  50. data/lib/rouge/demos/objective_c +14 -0
  51. data/lib/rouge/demos/ocaml +12 -0
  52. data/lib/rouge/demos/perl +5 -0
  53. data/lib/rouge/demos/php +3 -0
  54. data/lib/rouge/demos/plaintext +1 -0
  55. data/lib/rouge/demos/powershell +49 -0
  56. data/lib/rouge/demos/prolog +9 -0
  57. data/lib/rouge/demos/properties +7 -0
  58. data/lib/rouge/demos/puppet +6 -0
  59. data/lib/rouge/demos/python +6 -0
  60. data/lib/rouge/demos/qml +9 -0
  61. data/lib/rouge/demos/r +8 -0
  62. data/lib/rouge/demos/racket +24 -0
  63. data/lib/rouge/demos/ruby +9 -0
  64. data/lib/rouge/demos/rust +12 -0
  65. data/lib/rouge/demos/sass +3 -0
  66. data/lib/rouge/demos/scala +3 -0
  67. data/lib/rouge/demos/scheme +4 -0
  68. data/lib/rouge/demos/scss +5 -0
  69. data/lib/rouge/demos/sed +4 -0
  70. data/lib/rouge/demos/shell +2 -0
  71. data/lib/rouge/demos/slim +17 -0
  72. data/lib/rouge/demos/smalltalk +6 -0
  73. data/lib/rouge/demos/sml +4 -0
  74. data/lib/rouge/demos/sql +1 -0
  75. data/lib/rouge/demos/swift +5 -0
  76. data/lib/rouge/demos/tcl +1 -0
  77. data/lib/rouge/demos/tex +1 -0
  78. data/lib/rouge/demos/toml +9 -0
  79. data/lib/rouge/demos/tulip +14 -0
  80. data/lib/rouge/demos/vb +4 -0
  81. data/lib/rouge/demos/viml +5 -0
  82. data/lib/rouge/demos/xml +2 -0
  83. data/lib/rouge/demos/yaml +4 -0
  84. data/lib/rouge/formatter.rb +50 -0
  85. data/lib/rouge/formatters/html.rb +117 -0
  86. data/lib/rouge/formatters/null.rb +19 -0
  87. data/lib/rouge/formatters/terminal256.rb +176 -0
  88. data/lib/rouge/lexer.rb +443 -0
  89. data/lib/rouge/lexers/apache.rb +68 -0
  90. data/lib/rouge/lexers/apache/keywords.yml +453 -0
  91. data/lib/rouge/lexers/apple_script.rb +367 -0
  92. data/lib/rouge/lexers/c.rb +212 -0
  93. data/lib/rouge/lexers/clojure.rb +112 -0
  94. data/lib/rouge/lexers/coffeescript.rb +174 -0
  95. data/lib/rouge/lexers/common_lisp.rb +345 -0
  96. data/lib/rouge/lexers/conf.rb +24 -0
  97. data/lib/rouge/lexers/cpp.rb +66 -0
  98. data/lib/rouge/lexers/csharp.rb +88 -0
  99. data/lib/rouge/lexers/css.rb +271 -0
  100. data/lib/rouge/lexers/dart.rb +104 -0
  101. data/lib/rouge/lexers/diff.rb +31 -0
  102. data/lib/rouge/lexers/elixir.rb +108 -0
  103. data/lib/rouge/lexers/erb.rb +56 -0
  104. data/lib/rouge/lexers/erlang.rb +118 -0
  105. data/lib/rouge/lexers/factor.rb +302 -0
  106. data/lib/rouge/lexers/gherkin.rb +137 -0
  107. data/lib/rouge/lexers/gherkin/keywords.rb +14 -0
  108. data/lib/rouge/lexers/glsl.rb +135 -0
  109. data/lib/rouge/lexers/go.rb +178 -0
  110. data/lib/rouge/lexers/groovy.rb +104 -0
  111. data/lib/rouge/lexers/haml.rb +228 -0
  112. data/lib/rouge/lexers/handlebars.rb +79 -0
  113. data/lib/rouge/lexers/haskell.rb +183 -0
  114. data/lib/rouge/lexers/html.rb +94 -0
  115. data/lib/rouge/lexers/http.rb +80 -0
  116. data/lib/rouge/lexers/ini.rb +57 -0
  117. data/lib/rouge/lexers/io.rb +68 -0
  118. data/lib/rouge/lexers/java.rb +76 -0
  119. data/lib/rouge/lexers/javascript.rb +297 -0
  120. data/lib/rouge/lexers/liquid.rb +287 -0
  121. data/lib/rouge/lexers/literate_coffeescript.rb +33 -0
  122. data/lib/rouge/lexers/literate_haskell.rb +36 -0
  123. data/lib/rouge/lexers/llvm.rb +84 -0
  124. data/lib/rouge/lexers/lua.rb +122 -0
  125. data/lib/rouge/lexers/lua/builtins.rb +22 -0
  126. data/lib/rouge/lexers/make.rb +116 -0
  127. data/lib/rouge/lexers/markdown.rb +154 -0
  128. data/lib/rouge/lexers/matlab.rb +74 -0
  129. data/lib/rouge/lexers/matlab/builtins.rb +11 -0
  130. data/lib/rouge/lexers/moonscript.rb +110 -0
  131. data/lib/rouge/lexers/nginx.rb +71 -0
  132. data/lib/rouge/lexers/nim.rb +152 -0
  133. data/lib/rouge/lexers/objective_c.rb +197 -0
  134. data/lib/rouge/lexers/ocaml.rb +111 -0
  135. data/lib/rouge/lexers/perl.rb +197 -0
  136. data/lib/rouge/lexers/php.rb +173 -0
  137. data/lib/rouge/lexers/php/builtins.rb +204 -0
  138. data/lib/rouge/lexers/plain_text.rb +25 -0
  139. data/lib/rouge/lexers/powershell.rb +96 -0
  140. data/lib/rouge/lexers/prolog.rb +64 -0
  141. data/lib/rouge/lexers/properties.rb +55 -0
  142. data/lib/rouge/lexers/puppet.rb +128 -0
  143. data/lib/rouge/lexers/python.rb +228 -0
  144. data/lib/rouge/lexers/qml.rb +72 -0
  145. data/lib/rouge/lexers/r.rb +56 -0
  146. data/lib/rouge/lexers/racket.rb +542 -0
  147. data/lib/rouge/lexers/ruby.rb +415 -0
  148. data/lib/rouge/lexers/rust.rb +191 -0
  149. data/lib/rouge/lexers/sass.rb +74 -0
  150. data/lib/rouge/lexers/sass/common.rb +180 -0
  151. data/lib/rouge/lexers/scala.rb +142 -0
  152. data/lib/rouge/lexers/scheme.rb +112 -0
  153. data/lib/rouge/lexers/scss.rb +34 -0
  154. data/lib/rouge/lexers/sed.rb +170 -0
  155. data/lib/rouge/lexers/shell.rb +152 -0
  156. data/lib/rouge/lexers/slim.rb +228 -0
  157. data/lib/rouge/lexers/smalltalk.rb +116 -0
  158. data/lib/rouge/lexers/sml.rb +347 -0
  159. data/lib/rouge/lexers/sql.rb +140 -0
  160. data/lib/rouge/lexers/swift.rb +144 -0
  161. data/lib/rouge/lexers/tcl.rb +192 -0
  162. data/lib/rouge/lexers/tex.rb +72 -0
  163. data/lib/rouge/lexers/toml.rb +71 -0
  164. data/lib/rouge/lexers/tulip.rb +75 -0
  165. data/lib/rouge/lexers/vb.rb +164 -0
  166. data/lib/rouge/lexers/viml.rb +101 -0
  167. data/lib/rouge/lexers/viml/keywords.rb +12 -0
  168. data/lib/rouge/lexers/xml.rb +59 -0
  169. data/lib/rouge/lexers/yaml.rb +364 -0
  170. data/lib/rouge/plugins/redcarpet.rb +30 -0
  171. data/lib/rouge/regex_lexer.rb +439 -0
  172. data/lib/rouge/template_lexer.rb +22 -0
  173. data/lib/rouge/text_analyzer.rb +48 -0
  174. data/lib/rouge/theme.rb +195 -0
  175. data/lib/rouge/themes/base16.rb +130 -0
  176. data/lib/rouge/themes/colorful.rb +67 -0
  177. data/lib/rouge/themes/github.rb +71 -0
  178. data/lib/rouge/themes/molokai.rb +82 -0
  179. data/lib/rouge/themes/monokai.rb +92 -0
  180. data/lib/rouge/themes/monokai_sublime.rb +90 -0
  181. data/lib/rouge/themes/thankful_eyes.rb +71 -0
  182. data/lib/rouge/token.rb +182 -0
  183. data/lib/rouge/util.rb +101 -0
  184. data/lib/rouge/version.rb +7 -0
  185. metadata +231 -0
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # automatically generated by `rake builtins:lua`
3
+ module Rouge
4
+ module Lexers
5
+ class Lua
6
+ def self.builtins
7
+ @builtins ||= {}.tap do |b|
8
+ b["basic"] = Set.new %w(_G _VERSION assert collectgarbage dofile error getmetatable ipairs load loadfile next pairs pcall print rawequal rawget rawlen rawset select setmetatable tonumber tostring type xpcall file:close file:flush file:lines file:read file:seek file:setvbuf file:write)
9
+ b["modules"] = Set.new %w(require package.config package.cpath package.loaded package.loadlib package.path package.preload package.searchers package.searchpath)
10
+ b["bit32"] = Set.new %w(bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest bit32.bxor bit32.extract bit32.lrotate bit32.lshift bit32.replace bit32.rrotate bit32.rshift)
11
+ b["coroutine"] = Set.new %w(coroutine.create coroutine.resume coroutine.running coroutine.status coroutine.wrap coroutine.yield)
12
+ b["debug"] = Set.new %w(debug.debug debug.getuservalue debug.gethook debug.getinfo debug.getlocal debug.getmetatable debug.getregistry debug.getupvalue debug.setuservalue debug.sethook debug.setlocal debug.setmetatable debug.setupvalue debug.traceback debug.upvalueid debug.upvaluejoin)
13
+ b["io"] = Set.new %w(io.close io.flush io.input io.lines io.open io.output io.popen io.read io.stderr io.stdin io.stdout io.tmpfile io.type io.write)
14
+ b["math"] = Set.new %w(math.abs math.acos math.asin math.atan math.atan2 math.ceil math.cos math.cosh math.deg math.exp math.floor math.fmod math.frexp math.huge math.ldexp math.log math.max math.min math.modf math.pi math.pow math.rad math.random math.randomseed math.sin math.sinh math.sqrt math.tan math.tanh)
15
+ b["os"] = Set.new %w(os.clock os.date os.difftime os.execute os.exit os.getenv os.remove os.rename os.setlocale os.time os.tmpname)
16
+ b["string"] = Set.new %w(string.byte string.char string.dump string.find string.format string.gmatch string.gsub string.len string.lower string.match string.rep string.reverse string.sub string.upper)
17
+ b["table"] = Set.new %w(table.concat table.insert table.pack table.remove table.sort table.unpack)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,116 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Make < RegexLexer
6
+ title "Make"
7
+ desc "Makefile syntax"
8
+ tag 'make'
9
+ aliases 'makefile', 'mf', 'gnumake', 'bsdmake'
10
+ filenames '*.make', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'
11
+ mimetypes 'text/x-makefile'
12
+
13
+ def self.analyze_text(text)
14
+ return 0.6 if text =~ /^\.PHONY:/
15
+ end
16
+
17
+ bsd_special = %w(
18
+ include undef error warning if else elif endif for endfor
19
+ )
20
+
21
+ gnu_special = %w(
22
+ ifeq ifneq ifdef ifndef else endif include -include define endef :
23
+ )
24
+
25
+ line = /(?:\\.|\\\n|[^\\\n])*/m
26
+
27
+ def initialize(opts={})
28
+ super
29
+ @shell = Shell.new(opts)
30
+ end
31
+
32
+ start { @shell.reset! }
33
+
34
+ state :root do
35
+ rule /\s+/, Text
36
+
37
+ rule /#.*?\n/, Comment
38
+
39
+ rule /(export)(\s+)(?=[a-zA-Z0-9_\${}\t -]+\n)/ do
40
+ groups Keyword, Text
41
+ push :export
42
+ end
43
+
44
+ rule /export\s+/, Keyword
45
+
46
+ # assignment
47
+ rule /([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)/m do |m|
48
+ token Name::Variable, m[1]
49
+ token Text, m[2]
50
+ token Operator, m[3]
51
+ push :shell_line
52
+ end
53
+
54
+ rule /"(\\\\|\\.|[^"\\])*"/, Str::Double
55
+ rule /'(\\\\|\\.|[^'\\])*'/, Str::Single
56
+ rule /([^\n:]+)(:+)([ \t]*)/ do
57
+ groups Name::Label, Operator, Text
58
+ push :block_header
59
+ end
60
+ end
61
+
62
+ state :export do
63
+ rule /[\w\${}-]/, Name::Variable
64
+ rule /\n/, Text, :pop!
65
+ rule /\s+/, Text
66
+ end
67
+
68
+ state :block_header do
69
+ rule /[^,\\\n#]+/, Name::Function
70
+ rule /,/, Punctuation
71
+ rule /#.*?/, Comment
72
+ rule /\\\n/, Text
73
+ rule /\\./, Text
74
+ rule /\n/ do
75
+ token Text
76
+ goto :block_body
77
+ end
78
+ end
79
+
80
+ state :block_body do
81
+ rule /(\t[\t ]*)([@-]?)/ do |m|
82
+ groups Text, Punctuation
83
+ push :shell_line
84
+ end
85
+
86
+ rule(//) { @shell.reset!; pop! }
87
+ end
88
+
89
+ state :shell do
90
+ # macro interpolation
91
+ rule /\$\(\s*[a-z_]\w*\s*\)/i, Name::Variable
92
+ # $(shell ...)
93
+ rule /(\$\()(\s*)(shell)(\s+)/m do
94
+ groups Name::Function, Text, Name::Builtin, Text
95
+ push :shell_expr
96
+ end
97
+
98
+ rule(/\\./m) { delegate @shell }
99
+ stop = /\$\(|\(|\)|\n|\\/
100
+ rule(/.+?(?=#{stop})/m) { delegate @shell }
101
+ rule(stop) { delegate @shell }
102
+ end
103
+
104
+ state :shell_expr do
105
+ rule(/\(/) { delegate @shell; push }
106
+ rule /\)/, Name::Variable, :pop!
107
+ mixin :shell
108
+ end
109
+
110
+ state :shell_line do
111
+ rule /\n/, Text, :pop!
112
+ mixin :shell
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,154 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Markdown < RegexLexer
6
+ title "Markdown"
7
+ desc "Markdown, a light-weight markup language for authors"
8
+
9
+ tag 'markdown'
10
+ aliases 'md', 'mkd'
11
+ filenames '*.markdown', '*.md', '*.mkd'
12
+ mimetypes 'text/x-markdown'
13
+
14
+ def html
15
+ @html ||= HTML.new(options)
16
+ end
17
+
18
+ start { html.reset! }
19
+
20
+ edot = /\\.|[^\\\n]/
21
+
22
+ state :root do
23
+ # YAML frontmatter
24
+ rule(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m) { delegate YAML }
25
+
26
+ rule /\\./, Str::Escape
27
+
28
+ rule /^[\S ]+\n(?:---*)\n/, Generic::Heading
29
+ rule /^[\S ]+\n(?:===*)\n/, Generic::Subheading
30
+
31
+ rule /^#(?=[^#]).*?$/, Generic::Heading
32
+ rule /^##*.*?$/, Generic::Subheading
33
+
34
+ # TODO: syntax highlight the code block, github style
35
+ rule /(\n[ \t]*)(```|~~~)(.*?)(\n.*?)(\2)/m do |m|
36
+ sublexer = Lexer.find_fancy(m[3].strip, m[4])
37
+ sublexer ||= PlainText.new(:token => Str::Backtick)
38
+
39
+ token Text, m[1]
40
+ token Punctuation, m[2]
41
+ token Name::Label, m[3]
42
+ delegate sublexer, m[4]
43
+ token Punctuation, m[5]
44
+ end
45
+
46
+ rule /\n\n(( |\t).*?\n|\n)+/, Str::Backtick
47
+
48
+ rule /(`+)#{edot}*\1/, Str::Backtick
49
+
50
+ # various uses of * are in order of precedence
51
+
52
+ # line breaks
53
+ rule /^(\s*[*]){3,}\s*$/, Punctuation
54
+ rule /^(\s*[-]){3,}\s*$/, Punctuation
55
+
56
+ # bulleted lists
57
+ rule /^\s*[*+-](?=\s)/, Punctuation
58
+
59
+ # numbered lists
60
+ rule /^\s*\d+\./, Punctuation
61
+
62
+ # blockquotes
63
+ rule /^\s*>.*?$/, Generic::Traceback
64
+
65
+ # link references
66
+ # [foo]: bar "baz"
67
+ rule %r(^
68
+ (\s*) # leading whitespace
69
+ (\[) (#{edot}+?) (\]) # the reference
70
+ (\s*) (:) # colon
71
+ )x do
72
+ groups Text, Punctuation, Str::Symbol, Punctuation, Text, Punctuation
73
+
74
+ push :title
75
+ push :url
76
+ end
77
+
78
+ # links and images
79
+ rule /(!?\[)(#{edot}+?)(\])/ do
80
+ groups Punctuation, Name::Variable, Punctuation
81
+ push :link
82
+ end
83
+
84
+ rule /[*][*]#{edot}*?[*][*]/, Generic::Strong
85
+ rule /__#{edot}*?__/, Generic::Strong
86
+
87
+ rule /[*]#{edot}*?[*]/, Generic::Emph
88
+ rule /_#{edot}*?_/, Generic::Emph
89
+
90
+ # Automatic links
91
+ rule /<.*?@.+[.].+>/, Name::Variable
92
+ rule %r[<(https?|mailto|ftp)://#{edot}*?>], Name::Variable
93
+
94
+
95
+ rule /[^\\`\[*\n&<]+/, Text
96
+
97
+ # inline html
98
+ rule(/&\S*;/) { delegate html }
99
+ rule(/<#{edot}*?>/) { delegate html }
100
+ rule /[&<]/, Text
101
+
102
+ rule /\n/, Text
103
+ end
104
+
105
+ state :link do
106
+ rule /(\[)(#{edot}*?)(\])/ do
107
+ groups Punctuation, Str::Symbol, Punctuation
108
+ pop!
109
+ end
110
+
111
+ rule /[(]/ do
112
+ token Punctuation
113
+ push :inline_title
114
+ push :inline_url
115
+ end
116
+
117
+ rule /[ \t]+/, Text
118
+
119
+ rule(//) { pop! }
120
+ end
121
+
122
+ state :url do
123
+ rule /[ \t]+/, Text
124
+
125
+ # the url
126
+ rule /(<)(#{edot}*?)(>)/ do
127
+ groups Name::Tag, Str::Other, Name::Tag
128
+ pop!
129
+ end
130
+
131
+ rule /\S+/, Str::Other, :pop!
132
+ end
133
+
134
+ state :title do
135
+ rule /"#{edot}*?"/, Name::Namespace
136
+ rule /'#{edot}*?'/, Name::Namespace
137
+ rule /[(]#{edot}*?[)]/, Name::Namespace
138
+ rule /\s*(?=["'()])/, Text
139
+ rule(//) { pop! }
140
+ end
141
+
142
+ state :inline_title do
143
+ rule /[)]/, Punctuation, :pop!
144
+ mixin :title
145
+ end
146
+
147
+ state :inline_url do
148
+ rule /[^<\s)]+/, Str::Other, :pop!
149
+ rule /\s+/m, Text
150
+ mixin :url
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Matlab < RegexLexer
6
+ title "MATLAB"
7
+ desc "Matlab"
8
+ tag 'matlab'
9
+ aliases 'm'
10
+ filenames '*.m'
11
+ mimetypes 'text/x-matlab', 'application/x-matlab'
12
+
13
+ def self.analyze_text(text)
14
+ return 0.4 if text.match(/^\s*% /) # % comments are a dead giveaway
15
+ end
16
+
17
+ def self.keywords
18
+ @keywords = Set.new %w(
19
+ break case catch classdef continue else elseif end for function
20
+ global if otherwise parfor persistent return spmd switch try while
21
+ )
22
+ end
23
+
24
+ def self.builtins
25
+ load Pathname.new(__FILE__).dirname.join('matlab/builtins.rb')
26
+ self.builtins
27
+ end
28
+
29
+ state :root do
30
+ rule /\s+/m, Text # Whitespace
31
+ rule %r([{]%.*?%[}])m, Comment::Multiline
32
+ rule /%.*$/, Comment::Single
33
+ rule /([.][.][.])(.*?)$/ do
34
+ groups(Keyword, Comment)
35
+ end
36
+
37
+ rule /^(!)(.*?)(?=%|$)/ do |m|
38
+ token Keyword, m[1]
39
+ delegate Shell, m[2]
40
+ end
41
+
42
+
43
+ rule /[a-zA-Z][_a-zA-Z0-9]*/m do |m|
44
+ match = m[0]
45
+ if self.class.keywords.include? match
46
+ token Keyword
47
+ elsif self.class.builtins.include? match
48
+ token Name::Builtin
49
+ else
50
+ token Name
51
+ end
52
+ end
53
+
54
+ rule %r{[(){};:,\/\\\]\[]}, Punctuation
55
+
56
+ rule /~=|==|<<|>>|[-~+\/*%=<>&^|.]/, Operator
57
+
58
+
59
+ rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
60
+ rule /\d+e[+-]?[0-9]+/i, Num::Float
61
+ rule /\d+L/, Num::Integer::Long
62
+ rule /\d+/, Num::Integer
63
+
64
+ rule /'/, Str::Single, :string
65
+ end
66
+
67
+ state :string do
68
+ rule /[^']+/, Str::Single
69
+ rule /''/, Str::Escape
70
+ rule /'/, Str::Single, :pop!
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # automatically generated by `rake builtins:matlab`
3
+ module Rouge
4
+ module Lexers
5
+ class Matlab
6
+ def self.builtins
7
+ @builtins ||= Set.new %w(ans clc diary format home iskeyword more accumarray blkdiag diag eye false freqspace linspace logspace meshgrid ndgrid ones rand true zeros cat horzcat vertcat colon end ind2sub sub2ind length ndims numel size height width iscolumn isempty ismatrix isrow isscalar isvector blkdiag circshift ctranspose diag flip fliplr flipud ipermute permute repmat reshape rot90 shiftdim issorted sort sortrows squeeze transpose vectorize plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round relationaloperators eq ge gt le lt ne isequal isequaln logicaloperatorsshortcircuit and not or xor all any false find islogical logical true intersect ismember issorted setdiff setxor union unique join innerjoin outerjoin bitand bitcmp bitget bitor bitset bitshift bitxor swapbytes specialcharacters colon double single int8 int16 int32 int64 uint8 uint16 uint32 uint64 cast typecast isinteger isfloat isnumeric isreal isfinite isinf isnan eps flintmax inf intmax intmin nan realmax realmin blanks cellstr char iscellstr ischar sprintf strcat strjoin ischar isletter isspace isstrprop sscanf strfind strrep strsplit strtok validatestring symvar regexp regexpi regexprep regexptranslate strcmp strcmpi strncmp strncmpi blanks deblank strtrim lower upper strjust categorical iscategorical categories iscategory isordinal isprotected addcats mergecats removecats renamecats reordercats summary countcats isundefined table array2table cell2table struct2table table2array table2cell table2struct readtable writetable istable height width summary intersect ismember setdiff setxor unique union join innerjoin outerjoin sortrows stack unstack ismissing standardizemissing varfun rowfun struct fieldnames getfield isfield isstruct orderfields rmfield setfield arrayfun structfun table2struct struct2table cell2struct struct2cell cell cell2mat cell2struct cell2table celldisp cellfun cellplot cellstr iscell iscellstr mat2cell num2cell strjoin strsplit struct2cell table2cell function_handle feval func2str str2func localfunctions functions addevent delevent gettsafteratevent gettsafterevent gettsatevent gettsbeforeatevent gettsbeforeevent gettsbetweenevents gettscollection isemptytscollection lengthtscollection settscollection sizetscollection tscollection addsampletocollection addts delsamplefromcollection getabstimetscollection getsampleusingtimetscollection gettimeseriesnames horzcattscollection removets resampletscollection setabstimetscollection settimeseriesnames vertcattscollection is isa iscategorical iscell iscellstr ischar isfield isfloat ishghandle isinteger isjava islogical isnumeric isobject isreal isscalar isstr isstruct istable isvector class validateattributes whos char int2str mat2str num2str str2double str2num native2unicode unicode2native base2dec bin2dec dec2base dec2bin dec2hex hex2dec hex2num num2hex table2array table2cell table2struct array2table cell2table struct2table cell2mat cell2struct cellstr mat2cell num2cell struct2cell datenum datevec datestr now clock date calendar eomday weekday addtodate etime plus uplus minus uminus times rdivide ldivide power mtimes mrdivide mldivide mpower cumprod cumsum diff prod sum ceil fix floor idivide mod rem round sin sind asin asind sinh asinh cos cosd acos acosd cosh acosh tan tand atan atand atan2 atan2d tanh atanh csc cscd acsc acscd csch acsch sec secd asec asecd sech asech cot cotd acot acotd coth acoth hypot exp expm1 log log10 log1p log2 nextpow2 nthroot pow2 reallog realpow realsqrt sqrt abs angle complex conj cplxpair i imag isreal j real sign unwrap factor factorial gcd isprime lcm nchoosek perms primes rat rats poly polyder polyeig polyfit polyint polyval polyvalm residue roots airy besselh besseli besselj besselk bessely beta betainc betaincinv betaln ellipj ellipke erf erfc erfcinv erfcx erfinv expint gamma gammainc gammaincinv gammaln legendre psi cart2pol cart2sph pol2cart sph2cart eps flintmax i j inf pi nan isfinite isinf isnan compan gallery hadamard hankel hilb invhilb magic pascal rosser toeplitz vander wilkinson cross dot kron surfnorm tril triu transpose cond condest funm inv linsolve lscov lsqnonneg pinv rcond sylvester mldivide mrdivide chol ichol cholupdate ilu lu qr qrdelete qrinsert qrupdate planerot ldl cdf2rdf rsf2csf gsvd svd balance cdf2rdf condeig eig eigs gsvd hess ordeig ordqz ordschur poly polyeig qz rsf2csf schur sqrtm ss2tf svd svds bandwidth cond condeig det isbanded isdiag ishermitian issymmetric istril istriu norm normest null orth rank rcond rref subspace trace expm logm sqrtm bsxfun arrayfun accumarray mpower corrcoef cov max mean median min mode std var rand randn randi randperm rng interp1 pchip spline ppval mkpp unmkpp padecoef interpft interp2 interp3 interpn ndgrid meshgrid griddata griddatan fminbnd fminsearch fzero lsqnonneg optimget optimset ode45 ode15s ode23 ode113 ode23t ode23tb ode23s ode15i decic odextend odeget odeset deval bvp4c bvp5c bvpinit bvpxtend bvpget bvpset deval dde23 ddesd ddensd ddeget ddeset deval pdepe pdeval integral integral2 integral3 quadgk quad2d cumtrapz trapz polyint del2 diff gradient polyder abs angle cplxpair fft fft2 fftn fftshift fftw ifft ifft2 ifftn ifftshift nextpow2 unwrap conv conv2 convn deconv detrend filter filter2 spdiags speye sprand sprandn sprandsym sparse spconvert issparse nnz nonzeros nzmax spalloc spfun spones spparms spy find full amd colamd colperm dmperm randperm symamd symrcm condest eigs ichol ilu normest spaugment sprank svds bicg bicgstab bicgstabl cgs gmres lsqr minres pcg qmr symmlq tfqmr etree etreeplot gplot symbfact treelayout treeplot unmesh tetramesh trimesh triplot trisurf delaunay delaunayn tetramesh trimesh triplot trisurf dsearchn tsearchn delaunay delaunayn convhull convhulln patch trisurf patch voronoi voronoin polyarea inpolygon rectint plot plotyy plot3 loglog semilogx semilogy errorbar fplot ezplot ezplot3 linespec colorspec bar bar3 barh bar3h hist histc rose pareto area pie pie3 stem stairs stem3 scatter scatter3 spy plotmatrix polar rose compass ezpolar linespec colorspec contour contourf contourc contour3 contourslice ezcontour ezcontourf feather quiver compass quiver3 streamslice streamline surf surfc surface surfl surfnorm mesh meshc meshz waterfall ribbon contour3 peaks cylinder ellipsoid sphere pcolor surf2patch ezsurf ezsurfc ezmesh ezmeshc contourslice flow isocaps isocolors isonormals isosurface reducepatch reducevolume shrinkfaces slice smooth3 subvolume volumebounds coneplot curl divergence interpstreamspeed stream2 stream3 streamline streamparticles streamribbon streamslice streamtube fill fill3 patch surf2patch movie noanimate drawnow refreshdata frame2im getframe im2frame comet comet3 title xlabel ylabel zlabel clabel datetick texlabel legend colorbar xlim ylim zlim box grid daspect pbaspect axes axis subplot hold gca cla annotation text legend title xlabel ylabel zlabel datacursormode ginput gtext colormap colormapeditor colorbar brighten contrast shading graymon caxis hsv2rgb rgb2hsv rgbplot spinmap colordef whitebg hidden pan reset rotate rotate3d selectmoveresize zoom datacursormode figurepalette plotbrowser plotedit plottools propertyeditor showplottool brush datacursormode linkdata refreshdata view makehgtform viewmtx cameratoolbar campan camzoom camdolly camlookat camorbit campos camproj camroll camtarget camup camva camlight light lightangle lighting diffuse material specular alim alpha alphamap image imagesc imread imwrite imfinfo imformats frame2im im2frame im2java ind2rgb rgb2ind imapprox dither cmpermute cmunique print printopt printdlg printpreview orient savefig openfig hgexport hgsave hgload saveas gca gcf gcbf gcbo gco ancestor allchild findall findfigs findobj gobjects ishghandle ishandle copyobj delete get set propedit rootobject figure axes image light line patch rectangle surface text annotation set get hggroup hgtransform makehgtform figure gcf close clf refresh newplot shg closereq dragrect drawnow rbbox opengl axes hold ishold newplot linkaxes linkprop refreshdata waitfor get set if for parfor switch try while break continue end pause return edit input publish notebook grabcode snapnow function nargin nargout varargin varargout narginchk nargoutchk validateattributes validatestring inputname persistent isvarname namelengthmax assignin global isglobal try error warning lastwarn assert oncleanup dbclear dbcont dbdown dbquit dbstack dbstatus dbstep dbstop dbtype dbup checkcode keyboard mlintrpt edit echo eval evalc evalin feval run builtin mfilename pcode clear clearvars disp openvar who whos load save matfile importdata uiimport csvread csvwrite dlmread dlmwrite textscan readtable writetable type xlsfinfo xlsread xlswrite readtable writetable fclose feof ferror fgetl fgets fileread fopen fprintf fread frewind fscanf fseek ftell fwrite im2java imfinfo imread imwrite nccreate ncdisp ncinfo ncread ncreadatt ncwrite ncwriteatt ncwriteschema netcdf h5create h5disp h5info h5read h5readatt h5write h5writeatt hdfinfo hdfread imread imwrite hdfan hdfhx hdfh hdfhd hdfhe hdfml hdfpt hdfv hdfvf hdfvh hdfvs hdfdf24 hdfdfr8 fitsdisp fitsinfo fitsread fitswrite multibandread multibandwrite cdfepoch cdfinfo cdfread cdfwrite todatenum cdflib audioinfo audioread audiowrite mmfileinfo movie2avi audiodevinfo audioplayer audiorecorder sound soundsc beep lin2mu mu2lin xmlread xmlwrite xslt memmapfile dir ls pwd fileattrib exist isdir type visdiff what which cd copyfile delete recycle mkdir movefile rmdir open winopen fileparts fullfile filemarker filesep tempdir tempname matlabroot toolboxdir zip unzip gzip gunzip tar untar addpath rmpath path savepath userpath genpath pathsep pathtool restoredefaultpath clipboard computer dos getenv perl setenv system unix winqueryreg sendmail urlread urlwrite web instrcallback instrfind instrfindall readasync record serial serialbreak stopasync supportpackageinstaller raspi_examples targetupdater raspi raspi writeled showleds raspi configuredigitalpin readdigitalpin writedigitalpin showpins raspi raspi scani2cbus i2cdev readregister writeregister enablei2c disablei2c raspi spidev writeread enablespi disablespi raspi cameraboard raspi openshell getfile putfile deletefile webcamlist webcam preview snapshot closepreview guide inspect figure axes uicontrol uitable uipanel uibuttongroup actxcontrol uimenu uicontextmenu uitoolbar uipushtool uitoggletool dialog errordlg helpdlg msgbox questdlg uigetpref uisetpref waitbar warndlg export2wsdlg inputdlg listdlg uisetcolor uisetfont printdlg printpreview uigetdir uigetfile uiopen uiputfile uisave menu align movegui getpixelposition setpixelposition listfonts textwrap uistack uiwait uiresume waitfor waitforbuttonpress getappdata setappdata isappdata rmappdata guidata guihandles classdef class isa isequal isobject enumeration events methods properties classdef import properties isprop dynamicprops methods ismethod handle hgsetget dynamicprops isa events empty superclasses enumeration save load saveobj loadobj cat horzcat vertcat empty disp display numel size end subsref subsasgn subsindex substruct disp display details metaclass mexext inmem loadlibrary unloadlibrary libisloaded calllib libfunctions libfunctionsview libstruct libpointer javaarray javaclasspath javaaddpath javarmpath javachk isjava usejava javamethod javamethodedt javaobject javaobjectedt cell class clear depfun exist fieldnames im2java import inmem inspect isa methods methodsview which net enablenetfromnetworkdrive cell begininvoke endinvoke combine remove removeall bitand bitor bitxor bitnot actxserver actxcontrol actxcontrollist actxcontrolselect iscom addproperty deleteproperty inspect fieldnames methods methodsview invoke isevent eventlisteners registerevent unregisterallevents unregisterevent isinterface interfaces release move callsoapservice createclassfromwsdl createsoapmessage parsesoapresponse try addcausemexception getreportmexception lastmexception rethrowmexception throwmexception throwascallermexception mexception functiontests runtests bench cputime memory profile profsave tic timeit toc clear inmem memory pack whos commandhistory commandwindow filebrowser workspace getpref setpref addpref rmpref ispref builddocsearchdb mex execute getchararray putchararray getfullmatrix putfullmatrix getvariable getworkspacedata putworkspacedata maximizecommandwindow minimizecommandwindow actxgetrunningserver enableservice mex dbmex mexext inmem ver computer mexext dbmex inmem mex mexext checkin checkout cmopts customverctrl undocheckout verctrl matlabwindows matlabunix exit quit matlabrc startup finish prefdir preferences ismac ispc isstudent isunix javachk license usejava ver verlessthan version doc help docsearch lookfor demo echodemo)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,110 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ load_const :Lua, 'lua.rb'
6
+
7
+ class Moonscript < RegexLexer
8
+ title "MoonScript"
9
+ desc "Moonscript (http://www.moonscript.org)"
10
+ tag 'moonscript'
11
+ aliases 'moon'
12
+ filenames '*.moon'
13
+ mimetypes 'text/x-moonscript', 'application/x-moonscript'
14
+
15
+ def initialize(opts={})
16
+ @function_highlighting = opts.delete(:function_highlighting) { true }
17
+ @disabled_modules = opts.delete(:disabled_modules) { [] }
18
+ super(opts)
19
+ end
20
+
21
+ def self.analyze_text(text)
22
+ return 1 if text.shebang? 'moon'
23
+ end
24
+
25
+ def builtins
26
+ return [] unless @function_highlighting
27
+
28
+ @builtins ||= Set.new.tap do |builtins|
29
+ Rouge::Lexers::Lua.builtins.each do |mod, fns|
30
+ next if @disabled_modules.include? mod
31
+ builtins.merge(fns)
32
+ end
33
+ end
34
+ end
35
+
36
+ state :root do
37
+ rule %r(#!(.*?)$), Comment::Preproc # shebang
38
+ rule //, Text, :main
39
+ end
40
+
41
+ state :base do
42
+ ident = '(?:[\w_][\w\d_]*)'
43
+
44
+ rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), Num::Float
45
+ rule %r((?i)\d+e[+-]?\d+), Num::Float
46
+ rule %r((?i)0x[0-9a-f]*), Num::Hex
47
+ rule %r(\d+), Num::Integer
48
+ rule %r(@#{ident}*), Name::Variable::Instance
49
+ rule %r([A-Z][\w\d_]*), Name::Class
50
+ rule %r("?[^"]+":), Literal::String::Symbol
51
+ rule %r(#{ident}:), Literal::String::Symbol
52
+ rule %r(:#{ident}), Literal::String::Symbol
53
+
54
+ rule %r(\s+), Text::Whitespace
55
+ rule %r((==|~=|!=|<=|>=|\.\.\.|\.\.|->|=>|[=+\-*/%^<>#!\\])), Operator
56
+ rule %r([\[\]\{\}\(\)\.,:;]), Punctuation
57
+ rule %r((and|or|not)\b), Operator::Word
58
+
59
+ keywords = %w{
60
+ break class continue do else elseif end extends for if import in
61
+ repeat return switch super then unless until using when with while
62
+ }
63
+ rule %r((#{keywords.join('|')})\b), Keyword
64
+ rule %r((local|export)\b), Keyword::Declaration
65
+ rule %r((true|false|nil)\b), Keyword::Constant
66
+
67
+ rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m|
68
+ name = m[0]
69
+ if self.builtins.include?(name)
70
+ token Name::Builtin
71
+ elsif name =~ /\./
72
+ a, b = name.split('.', 2)
73
+ token Name, a
74
+ token Punctuation, '.'
75
+ token Name, b
76
+ else
77
+ token Name
78
+ end
79
+ end
80
+ end
81
+
82
+ state :main do
83
+ rule %r(--.*$), Comment::Single
84
+ rule %r(\[(=*)\[.*?\]\1\])m, Str::Heredoc
85
+
86
+ mixin :base
87
+
88
+ rule %r('), Str::Single, :sqs
89
+ rule %r("), Str::Double, :dqs
90
+ end
91
+
92
+ state :sqs do
93
+ rule %r('), Str::Single, :pop!
94
+ rule %r([^']+), Str::Single
95
+ end
96
+
97
+ state :interpolation do
98
+ rule %r(\}), Str::Interpol, :pop!
99
+ mixin :base
100
+ end
101
+
102
+ state :dqs do
103
+ rule %r(#\{), Str::Interpol, :interpolation
104
+ rule %r("), Str::Double, :pop!
105
+ rule %r(#[^{]), Str::Double
106
+ rule %r([^"#]+), Str::Double
107
+ end
108
+ end
109
+ end
110
+ end