rouge 0.2.14 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,61 +38,7 @@ load load_dir.join('rouge/lexer.rb')
38
38
  load load_dir.join('rouge/regex_lexer.rb')
39
39
  load load_dir.join('rouge/template_lexer.rb')
40
40
 
41
- load load_dir.join('rouge/lexers/text.rb')
42
- load load_dir.join('rouge/lexers/diff.rb')
43
- load load_dir.join('rouge/lexers/tex.rb')
44
- load load_dir.join('rouge/lexers/markdown.rb')
45
- load load_dir.join('rouge/lexers/yaml.rb')
46
- load load_dir.join('rouge/lexers/toml.rb')
47
- load load_dir.join('rouge/lexers/ini.rb')
48
-
49
- load load_dir.join('rouge/lexers/sql.rb')
50
-
51
- load load_dir.join('rouge/lexers/make.rb')
52
- load load_dir.join('rouge/lexers/shell.rb')
53
- load load_dir.join('rouge/lexers/viml.rb')
54
- load load_dir.join('rouge/lexers/nginx.rb')
55
- load load_dir.join('rouge/lexers/conf.rb')
56
- load load_dir.join('rouge/lexers/sed.rb')
57
- load load_dir.join('rouge/lexers/puppet.rb')
58
-
59
- load load_dir.join('rouge/lexers/javascript.rb')
60
- load load_dir.join('rouge/lexers/css.rb')
61
- load load_dir.join('rouge/lexers/html.rb')
62
- load load_dir.join('rouge/lexers/xml.rb')
63
- load load_dir.join('rouge/lexers/php.rb')
64
-
65
- load load_dir.join('rouge/lexers/haml.rb')
66
- load load_dir.join('rouge/lexers/sass.rb')
67
- load load_dir.join('rouge/lexers/scss.rb')
68
- load load_dir.join('rouge/lexers/coffeescript.rb')
69
- load load_dir.join('rouge/lexers/literate_coffeescript.rb')
70
-
71
- load load_dir.join('rouge/lexers/erb.rb')
72
- load load_dir.join('rouge/lexers/handlebars.rb')
73
-
74
- load load_dir.join('rouge/lexers/tcl.rb')
75
- load load_dir.join('rouge/lexers/python.rb')
76
- load load_dir.join('rouge/lexers/ruby.rb')
77
- load load_dir.join('rouge/lexers/perl.rb')
78
- load load_dir.join('rouge/lexers/factor.rb')
79
- load load_dir.join('rouge/lexers/clojure.rb')
80
- load load_dir.join('rouge/lexers/groovy.rb')
81
- load load_dir.join('rouge/lexers/io.rb')
82
-
83
- load load_dir.join('rouge/lexers/haskell.rb')
84
- load load_dir.join('rouge/lexers/literate_haskell.rb')
85
- load load_dir.join('rouge/lexers/scheme.rb')
86
- load load_dir.join('rouge/lexers/common_lisp.rb')
87
-
88
- load load_dir.join('rouge/lexers/c.rb')
89
- load load_dir.join('rouge/lexers/cpp.rb')
90
- load load_dir.join('rouge/lexers/java.rb')
91
- load load_dir.join('rouge/lexers/rust.rb')
92
-
93
- load load_dir.join('rouge/lexers/csharp.rb')
94
-
95
- load load_dir.join('rouge/lexers/smalltalk.rb')
41
+ Dir.glob(load_dir.join('rouge/lexers/*.rb')).each { |f| load f }
96
42
 
97
43
  load load_dir.join('rouge/formatter.rb')
98
44
  load load_dir.join('rouge/formatters/html.rb')
@@ -0,0 +1,4 @@
1
+ ; last modified 1 April 2001 by John Doe
2
+ [owner]
3
+ name=John Doe
4
+ organization=Acme Widgets Inc.
@@ -0,0 +1,12 @@
1
+ -- defines a factorial function
2
+ function fact (n)
3
+ if n == 0 then
4
+ return 1
5
+ else
6
+ return n * fact(n-1)
7
+ end
8
+ end
9
+
10
+ print("enter a number:")
11
+ a = io.read("*number") -- read a number
12
+ print(fact(a))
@@ -0,0 +1,9 @@
1
+ # This is a TOML document. Boom.
2
+
3
+ title = "TOML Example"
4
+
5
+ [owner]
6
+ name = "Tom Preston-Werner"
7
+ organization = "GitHub"
8
+ bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
9
+ dob = 1979-05-27T07:32:00Z # First class dates? Why not?
@@ -0,0 +1,125 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Lua < RegexLexer
4
+ desc "Lua (http://www.lua.org)"
5
+ tag 'lua'
6
+ filenames '*.lua', '*.wlua'
7
+
8
+ mimetypes 'text/x-lua', 'application/x-lua'
9
+
10
+ def initialize(opts={})
11
+ @function_highlighting = opts.delete(:function_highlighting) { true }
12
+ @disabled_modules = opts.delete(:disabled_modules) { [] }
13
+ super(opts)
14
+ end
15
+
16
+ def self.analyze_text(text)
17
+ return 1 if text.shebang? 'lua'
18
+ end
19
+
20
+ def self.builtins
21
+ load Pathname.new(__FILE__).dirname.join('lua/builtins.rb')
22
+ self.builtins
23
+ end
24
+
25
+ def builtins
26
+ return [] unless @function_highlighting
27
+
28
+ @builtins ||= Set.new.tap do |builtins|
29
+ self.class.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
+ # lua allows a file to start with a shebang
38
+ rule %r(#!(.*?)$), 'Comment.Preproc'
39
+ rule //, 'Text', :base
40
+ end
41
+
42
+ state :base do
43
+ rule %r(--\[(=*)\[.*?\]\1\])ms, 'Comment.Multiline'
44
+ rule %r(--.*$), 'Comment.Single'
45
+
46
+ rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), 'Literal.Number.Float'
47
+ rule %r((?i)\d+e[+-]?\d+), 'Literal.Number.Float'
48
+ rule %r((?i)0x[0-9a-f]*), 'Literal.Number.Hex'
49
+ rule %r(\d+), 'Literal.Number.Integer'
50
+
51
+ rule %r(\n), 'Text'
52
+ rule %r([^\S\n]), 'Text'
53
+ # multiline strings
54
+ rule %r(\[(=*)\[.*?\]\1\])ms, 'Literal.String'
55
+
56
+ rule %r((==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])), 'Operator'
57
+ rule %r([\[\]\{\}\(\)\.,:;]), 'Punctuation'
58
+ rule %r((and|or|not)\b), 'Operator.Word'
59
+
60
+ rule %r((break|do|else|elseif|end|for|if|in|repeat|return|then|until|while)\b), 'Keyword'
61
+ rule %r((local)\b), 'Keyword.Declaration'
62
+ rule %r((true|false|nil)\b), 'Keyword.Constant'
63
+
64
+ rule %r((function)\b), 'Keyword', :function_name
65
+
66
+ rule %r([A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?) do |m|
67
+ name = m[0]
68
+ if self.builtins.include?(name)
69
+ token 'Name.Builtin'
70
+ elsif name =~ /\./
71
+ a, b = name.split('.', 2)
72
+ token 'Name', a
73
+ token 'Punctuation', '.'
74
+ token 'Name', b
75
+ else
76
+ token 'Name'
77
+ end
78
+ end
79
+
80
+ rule %r('), 'Literal.String.Single', :escape_sqs
81
+ rule %r("), 'Literal.String.Double', :escape_dqs
82
+ end
83
+
84
+ state :function_name do
85
+ rule /\s+/, 'Text'
86
+ rule %r((?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)) do
87
+ group 'Name.Class'; group 'Punctuation'; group 'Name.Function'
88
+ pop!
89
+ end
90
+ # inline function
91
+ rule %r(\(), 'Punctuation', :pop!
92
+ end
93
+
94
+ state :escape_sqs do
95
+ mixin :string_escape
96
+ mixin :sqs
97
+ end
98
+
99
+ state :escape_dqs do
100
+ mixin :string_escape
101
+ mixin :dqs
102
+ end
103
+
104
+ state :string_escape do
105
+ rule %r(\\([abfnrtv\\"']|\d{1,3})), 'Literal.String.Escape'
106
+ end
107
+
108
+ state :sqs do
109
+ rule %r('), 'Literal.String', :pop!
110
+ mixin :string
111
+ end
112
+
113
+ state :dqs do
114
+ rule %r("), 'Literal.String', :pop!
115
+ mixin :string
116
+ end
117
+
118
+ # Lua is 8-bit clean, every character is valid in a string
119
+ state :string do
120
+ rule /./, 'Literal.String'
121
+ end
122
+
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,21 @@
1
+ # automatically generated by `rake builtins:lua`
2
+ module Rouge
3
+ module Lexers
4
+ class Lua
5
+ def self.builtins
6
+ @builtins ||= {}.tap do |b|
7
+ b["basic"] = Set.new %w(_G _VERSION assert collectgarbage dofile error getmetatable ipairs loadfile load 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)
8
+ b["modules"] = Set.new %w(require package.config package.cpath package.loaded package.loadlib package.path package.preload package.searchers package.searchpath)
9
+ 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)
10
+ b["coroutine"] = Set.new %w(coroutine.create coroutine.resume coroutine.running coroutine.status coroutine.wrap coroutine.yield)
11
+ 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)
12
+ 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)
13
+ 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)
14
+ 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)
15
+ 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)
16
+ b["table"] = Set.new %w(table.concat table.insert table.pack table.remove table.sort table.unpack)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,8 @@ module Rouge
5
5
  tag 'ruby'
6
6
  aliases 'rb'
7
7
  filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec',
8
- 'Rakefile', 'Guardfile', 'Gemfile'
8
+ 'Rakefile', 'Guardfile', 'Gemfile', 'Capfile',
9
+ 'Vagrantfile', '*.ru', '*.prawn'
9
10
 
10
11
  mimetypes 'text/x-ruby', 'application/x-ruby'
11
12
 
@@ -1,7 +1,7 @@
1
1
  module Rouge
2
2
  module Lexers
3
3
  class TOML < RegexLexer
4
- desc 'the TOML configuration format'
4
+ desc 'the TOML configuration format (https://github.com/mojombo/toml)'
5
5
  tag 'toml'
6
6
 
7
7
  filenames '*.toml'
@@ -51,6 +51,7 @@ module Rouge
51
51
  style 'Name.Label',
52
52
  'Name.Tag', :fg => :schrill, :bold => true
53
53
  style 'Literal.Number',
54
+ 'Literal.Date',
54
55
  'Literal.String.Symbol', :fg => :pink_merengue, :bold => true
55
56
  style 'Literal.String', :fg => :dune, :bold => true
56
57
  style 'Literal.String.Escape',
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.2.14"
3
+ "0.2.15"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-01 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -85,6 +85,7 @@ files:
85
85
  - lib/rouge/lexers/shell.rb
86
86
  - lib/rouge/lexers/yaml.rb
87
87
  - lib/rouge/lexers/make.rb
88
+ - lib/rouge/lexers/lua.rb
88
89
  - lib/rouge/lexers/viml.rb
89
90
  - lib/rouge/lexers/java.rb
90
91
  - lib/rouge/lexers/common_lisp.rb
@@ -94,6 +95,7 @@ files:
94
95
  - lib/rouge/lexers/literate_haskell.rb
95
96
  - lib/rouge/lexers/c.rb
96
97
  - lib/rouge/lexers/io.rb
98
+ - lib/rouge/lexers/lua/builtins.rb
97
99
  - lib/rouge/lexers/python.rb
98
100
  - lib/rouge/lexers/cpp.rb
99
101
  - lib/rouge/lexers/sql.rb
@@ -135,15 +137,18 @@ files:
135
137
  - lib/rouge/demos/common_lisp
136
138
  - lib/rouge/demos/groovy
137
139
  - lib/rouge/demos/nginx
140
+ - lib/rouge/demos/toml
138
141
  - lib/rouge/demos/rust
139
142
  - lib/rouge/demos/json
140
143
  - lib/rouge/demos/markdown
141
144
  - lib/rouge/demos/xml
145
+ - lib/rouge/demos/lua
142
146
  - lib/rouge/demos/erb
143
147
  - lib/rouge/demos/cpp
144
148
  - lib/rouge/demos/coffeescript
145
149
  - lib/rouge/demos/sql
146
150
  - lib/rouge/demos/puppet
151
+ - lib/rouge/demos/ini
147
152
  - lib/rouge/demos/scheme
148
153
  - lib/rouge/demos/diff
149
154
  homepage: http://github.com/jayferd/rouge