rouge 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5ef3d5ad63da7030f7010aa8a8cf106ab9e996a
4
- data.tar.gz: 57de8eafa29b51cce4cb7370b9848a9791b1ec5c
3
+ metadata.gz: 655cf7caf531705969ba4dd70fb14e844d402ace
4
+ data.tar.gz: 7c9aa4d4c38cdf6664fd65aefd61ef487f6946bb
5
5
  SHA512:
6
- metadata.gz: 9177cafdf9183ecf4f9a28044fae665cd2fc26e684e1168ca591139e52f87ff40d426cc74a8b2520cceaa3824395c28009839de6fd9b1b4695b106ce362b7835
7
- data.tar.gz: 4b9e68100dce51cf3475d581b40285ed7194857824c5356158b1502a59940d323f06b0de0169a842338e047b87a58773a92a93d70e1628e5f29d573d99dfcaab
6
+ metadata.gz: 1a2f19f1a538b2adb688dfdd921dfae66062dc8a3d6966c3fd9ad27165f3e00fe7451fce1078d3967605e30e04469ff5acc469b485b37f97d5f131e090d61783
7
+ data.tar.gz: 5e4103ce369d28143b452d912f91f733b2369eeb098ee4aa6fc388f88404a0519dd1845919401caea10f2c42838fe32fbbdd53ab1cbe7a715f9d910323876c32
@@ -43,7 +43,7 @@ module Rouge
43
43
  tokens.each do |tok, val|
44
44
  span(tok, val, &b)
45
45
  end
46
- yield '</pre>' if @wrap
46
+ yield "</pre>\n" if @wrap
47
47
  end
48
48
 
49
49
  def stream_tableized(tokens)
@@ -82,8 +82,8 @@ module Rouge
82
82
  yield '</pre>'
83
83
  yield '</td>'
84
84
 
85
- yield '</tr></tbody></table>'
86
- yield '</div>' if @wrap
85
+ yield "</tr></tbody></table>\n"
86
+ yield "</div>\n" if @wrap
87
87
  end
88
88
 
89
89
  TABLE_FOR_ESCAPE_HTML = {
@@ -11,41 +11,49 @@ module Rouge
11
11
  return 1 if text.shebang?(/pythonw?(3|2(\.\d)?)?/)
12
12
  end
13
13
 
14
- keywords = %w(
15
- assert break continue del elif else except exec
16
- finally for global if lambda pass print raise
17
- return try while yield as with
18
- )
19
-
20
- builtins = %w(
21
- __import__ abs all any apply basestring bin bool buffer
22
- bytearray bytes callable chr classmethod cmp coerce compile
23
- complex delattr dict dir divmod enumerate eval execfile exit
24
- file filter float frozenset getattr globals hasattr hash hex id
25
- input int intern isinstance issubclass iter len list locals
26
- long map max min next object oct open ord pow property range
27
- raw_input reduce reload repr reversed round set setattr slice
28
- sorted staticmethod str sum super tuple type unichr unicode
29
- vars xrange zip
30
- )
31
-
32
- builtins_pseudo = %w(self None Ellipsis NotImplemented False True)
33
-
34
- exceptions = %w(
35
- ArithmeticError AssertionError AttributeError
36
- BaseException DeprecationWarning EOFError EnvironmentError
37
- Exception FloatingPointError FutureWarning GeneratorExit IOError
38
- ImportError ImportWarning IndentationError IndexError KeyError
39
- KeyboardInterrupt LookupError MemoryError NameError
40
- NotImplemented NotImplementedError OSError OverflowError
41
- OverflowWarning PendingDeprecationWarning ReferenceError
42
- RuntimeError RuntimeWarning StandardError StopIteration
43
- SyntaxError SyntaxWarning SystemError SystemExit TabError
44
- TypeError UnboundLocalError UnicodeDecodeError
45
- UnicodeEncodeError UnicodeError UnicodeTranslateError
46
- UnicodeWarning UserWarning ValueError VMSError Warning
47
- WindowsError ZeroDivisionError
48
- )
14
+ def self.keywords
15
+ @keywords ||= %w(
16
+ assert break continue del elif else except exec
17
+ finally for global if lambda pass print raise
18
+ return try while yield as with
19
+ )
20
+ end
21
+
22
+ def self.builtins
23
+ @builtins ||= %w(
24
+ __import__ abs all any apply basestring bin bool buffer
25
+ bytearray bytes callable chr classmethod cmp coerce compile
26
+ complex delattr dict dir divmod enumerate eval execfile exit
27
+ file filter float frozenset getattr globals hasattr hash hex id
28
+ input int intern isinstance issubclass iter len list locals
29
+ long map max min next object oct open ord pow property range
30
+ raw_input reduce reload repr reversed round set setattr slice
31
+ sorted staticmethod str sum super tuple type unichr unicode
32
+ vars xrange zip
33
+ )
34
+ end
35
+
36
+ def self.builtins_pseudo
37
+ @builtins_pseudo ||= %w(self None Ellipsis NotImplemented False True)
38
+ end
39
+
40
+ def self.exceptions
41
+ @exceptions ||= %w(
42
+ ArithmeticError AssertionError AttributeError
43
+ BaseException DeprecationWarning EOFError EnvironmentError
44
+ Exception FloatingPointError FutureWarning GeneratorExit IOError
45
+ ImportError ImportWarning IndentationError IndexError KeyError
46
+ KeyboardInterrupt LookupError MemoryError NameError
47
+ NotImplemented NotImplementedError OSError OverflowError
48
+ OverflowWarning PendingDeprecationWarning ReferenceError
49
+ RuntimeError RuntimeWarning StandardError StopIteration
50
+ SyntaxError SyntaxWarning SystemError SystemExit TabError
51
+ TypeError UnboundLocalError UnicodeDecodeError
52
+ UnicodeEncodeError UnicodeError UnicodeTranslateError
53
+ UnicodeWarning UserWarning ValueError VMSError Warning
54
+ WindowsError ZeroDivisionError
55
+ )
56
+ end
49
57
 
50
58
  identifier = /[a-z_][a-z0-9_]*/i
51
59
  dotted_identifier = /[a-z_.][a-z0-9_.]*/i
@@ -64,8 +72,6 @@ module Rouge
64
72
  rule /(in|is|and|or|not)\b/, Operator::Word
65
73
  rule /!=|==|<<|>>|[-~+\/*%=<>&^|.]/, Operator
66
74
 
67
- rule /(?:#{keywords.join('|')})\b/, Keyword
68
-
69
75
  rule /(def)((?:\s|\\\s)+)/ do
70
76
  groups Keyword, Text
71
77
  push :funcname
@@ -86,10 +92,6 @@ module Rouge
86
92
  push :import
87
93
  end
88
94
 
89
- # using negative lookbehind so we don't match property names
90
- rule /(?<!\.)(?:#{builtins.join('|')})/, Name::Builtin
91
- rule /(?<!\.)(?:#{builtins_pseudo.join('|')})/, Name::Builtin::Pseudo
92
-
93
95
  # TODO: not in python 3
94
96
  rule /`.*?`/, Str::Backtick
95
97
  rule /(?:r|ur|ru)"""/i, Str, :tdqs
@@ -102,6 +104,22 @@ module Rouge
102
104
  rule /u?'/i, Str, :escape_sqs
103
105
 
104
106
  rule /@#{dotted_identifier}/i, Name::Decorator
107
+
108
+ # using negative lookbehind so we don't match property names
109
+ rule /(?<!\.)#{identifier}/ do |m|
110
+ if self.class.keywords.include? m[0]
111
+ token Keyword
112
+ elsif self.class.exceptions.include? m[0]
113
+ token Name::Builtin
114
+ elsif self.class.builtins.include? m[0]
115
+ token Name::Builtin
116
+ elsif self.class.builtins_pseudo.include? m[0]
117
+ token Name::Builtin::Pseudo
118
+ else
119
+ token Name
120
+ end
121
+ end
122
+
105
123
  rule identifier, Name
106
124
 
107
125
  rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
@@ -99,6 +99,11 @@ module Rouge
99
99
  puts " popping stack: #{1}" if @debug
100
100
  @stack.pop or raise 'empty stack!'
101
101
  end
102
+ when :push
103
+ proc do |stream|
104
+ puts " pushing #{@stack.last.name}" if @debug
105
+ @stack.push(@stack.last)
106
+ end
102
107
  when Symbol
103
108
  proc do |stream|
104
109
  puts " yielding #{tok.qualname}, #{stream[0].inspect}" if @debug
data/lib/rouge/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "1.3.2"
3
+ "1.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
14
  email:
@@ -20,158 +20,158 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - Gemfile
22
22
  - LICENSE
23
- - bin/rougify
24
- - lib/rouge.rb
25
- - lib/rouge/cli.rb
26
- - lib/rouge/demos/c
27
- - lib/rouge/demos/clojure
28
- - lib/rouge/demos/coffeescript
29
- - lib/rouge/demos/common_lisp
30
- - lib/rouge/demos/conf
31
- - lib/rouge/demos/cpp
32
- - lib/rouge/demos/csharp
33
- - lib/rouge/demos/css
34
- - lib/rouge/demos/diff
35
- - lib/rouge/demos/elixir
36
- - lib/rouge/demos/erb
37
- - lib/rouge/demos/erlang
38
- - lib/rouge/demos/factor
39
- - lib/rouge/demos/gherkin
40
- - lib/rouge/demos/go
41
- - lib/rouge/demos/groovy
42
- - lib/rouge/demos/haml
43
- - lib/rouge/demos/handlebars
44
- - lib/rouge/demos/haskell
45
- - lib/rouge/demos/html
46
- - lib/rouge/demos/http
47
- - lib/rouge/demos/ini
48
- - lib/rouge/demos/io
49
- - lib/rouge/demos/java
50
- - lib/rouge/demos/javascript
51
- - lib/rouge/demos/json
52
- - lib/rouge/demos/literate_coffeescript
53
- - lib/rouge/demos/literate_haskell
54
- - lib/rouge/demos/llvm
55
- - lib/rouge/demos/lua
56
- - lib/rouge/demos/make
57
- - lib/rouge/demos/markdown
58
- - lib/rouge/demos/matlab
59
- - lib/rouge/demos/moonscript
60
- - lib/rouge/demos/nginx
61
- - lib/rouge/demos/objective_c
62
- - lib/rouge/demos/ocaml
63
- - lib/rouge/demos/perl
64
- - lib/rouge/demos/php
65
- - lib/rouge/demos/plaintext
66
- - lib/rouge/demos/prolog
67
- - lib/rouge/demos/puppet
68
- - lib/rouge/demos/python
69
- - lib/rouge/demos/r
70
- - lib/rouge/demos/racket
71
- - lib/rouge/demos/ruby
72
- - lib/rouge/demos/rust
73
- - lib/rouge/demos/sass
74
- - lib/rouge/demos/scala
75
- - lib/rouge/demos/scheme
76
- - lib/rouge/demos/scss
77
- - lib/rouge/demos/sed
78
- - lib/rouge/demos/shell
79
- - lib/rouge/demos/smalltalk
80
- - lib/rouge/demos/sml
81
- - lib/rouge/demos/sql
82
- - lib/rouge/demos/tcl
83
- - lib/rouge/demos/tex
84
- - lib/rouge/demos/toml
85
- - lib/rouge/demos/vb
86
- - lib/rouge/demos/viml
87
- - lib/rouge/demos/xml
88
- - lib/rouge/demos/yaml
23
+ - rouge.gemspec
24
+ - lib/rouge/token.rb
25
+ - lib/rouge/version.rb
26
+ - lib/rouge/util.rb
27
+ - lib/rouge/theme.rb
28
+ - lib/rouge/lexer.rb
29
+ - lib/rouge/template_lexer.rb
89
30
  - lib/rouge/formatter.rb
31
+ - lib/rouge/plugins/redcarpet.rb
32
+ - lib/rouge/cli.rb
90
33
  - lib/rouge/formatters/html.rb
91
34
  - lib/rouge/formatters/terminal256.rb
92
- - lib/rouge/lexer.rb
93
- - lib/rouge/lexers/c.rb
35
+ - lib/rouge/themes/thankful_eyes.rb
36
+ - lib/rouge/themes/base16.rb
37
+ - lib/rouge/themes/github.rb
38
+ - lib/rouge/themes/monokai.rb
39
+ - lib/rouge/themes/colorful.rb
40
+ - lib/rouge/text_analyzer.rb
41
+ - lib/rouge/regex_lexer.rb
42
+ - lib/rouge/lexers/html.rb
43
+ - lib/rouge/lexers/smalltalk.rb
94
44
  - lib/rouge/lexers/clojure.rb
95
- - lib/rouge/lexers/coffeescript.rb
96
- - lib/rouge/lexers/common_lisp.rb
97
- - lib/rouge/lexers/conf.rb
98
- - lib/rouge/lexers/cpp.rb
99
- - lib/rouge/lexers/csharp.rb
100
- - lib/rouge/lexers/css.rb
101
- - lib/rouge/lexers/diff.rb
102
- - lib/rouge/lexers/elixir.rb
103
- - lib/rouge/lexers/erb.rb
104
- - lib/rouge/lexers/erlang.rb
45
+ - lib/rouge/lexers/plain_text.rb
46
+ - lib/rouge/lexers/sass/common.rb
47
+ - lib/rouge/lexers/sass.rb
105
48
  - lib/rouge/lexers/factor.rb
106
- - lib/rouge/lexers/gherkin.rb
107
- - lib/rouge/lexers/gherkin/keywords.rb
108
- - lib/rouge/lexers/go.rb
49
+ - lib/rouge/lexers/csharp.rb
50
+ - lib/rouge/lexers/php/builtins.rb
51
+ - lib/rouge/lexers/nginx.rb
52
+ - lib/rouge/lexers/llvm.rb
53
+ - lib/rouge/lexers/scala.rb
54
+ - lib/rouge/lexers/perl.rb
109
55
  - lib/rouge/lexers/groovy.rb
110
- - lib/rouge/lexers/haml.rb
111
- - lib/rouge/lexers/handlebars.rb
112
- - lib/rouge/lexers/haskell.rb
113
- - lib/rouge/lexers/html.rb
114
- - lib/rouge/lexers/http.rb
115
- - lib/rouge/lexers/ini.rb
116
- - lib/rouge/lexers/io.rb
117
- - lib/rouge/lexers/java.rb
118
- - lib/rouge/lexers/javascript.rb
56
+ - lib/rouge/lexers/sed.rb
57
+ - lib/rouge/lexers/coffeescript.rb
119
58
  - lib/rouge/lexers/literate_coffeescript.rb
120
- - lib/rouge/lexers/literate_haskell.rb
121
- - lib/rouge/lexers/llvm.rb
122
- - lib/rouge/lexers/lua.rb
123
- - lib/rouge/lexers/lua/builtins.rb
124
- - lib/rouge/lexers/make.rb
125
- - lib/rouge/lexers/markdown.rb
126
- - lib/rouge/lexers/matlab.rb
127
- - lib/rouge/lexers/matlab/builtins.rb
59
+ - lib/rouge/lexers/racket.rb
60
+ - lib/rouge/lexers/diff.rb
61
+ - lib/rouge/lexers/viml/keywords.rb
62
+ - lib/rouge/lexers/css.rb
63
+ - lib/rouge/lexers/toml.rb
128
64
  - lib/rouge/lexers/moonscript.rb
129
- - lib/rouge/lexers/nginx.rb
130
- - lib/rouge/lexers/objective_c.rb
131
- - lib/rouge/lexers/ocaml.rb
132
- - lib/rouge/lexers/perl.rb
133
- - lib/rouge/lexers/php.rb
134
- - lib/rouge/lexers/php/builtins.rb
135
- - lib/rouge/lexers/plain_text.rb
136
- - lib/rouge/lexers/prolog.rb
137
65
  - lib/rouge/lexers/puppet.rb
138
- - lib/rouge/lexers/python.rb
139
- - lib/rouge/lexers/r.rb
140
- - lib/rouge/lexers/racket.rb
141
66
  - lib/rouge/lexers/ruby.rb
67
+ - lib/rouge/lexers/http.rb
68
+ - lib/rouge/lexers/xml.rb
69
+ - lib/rouge/lexers/handlebars.rb
70
+ - lib/rouge/lexers/php.rb
71
+ - lib/rouge/lexers/tcl.rb
72
+ - lib/rouge/lexers/tex.rb
73
+ - lib/rouge/lexers/gherkin.rb
74
+ - lib/rouge/lexers/vb.rb
142
75
  - lib/rouge/lexers/rust.rb
143
- - lib/rouge/lexers/sass.rb
144
- - lib/rouge/lexers/sass/common.rb
145
- - lib/rouge/lexers/scala.rb
146
- - lib/rouge/lexers/scheme.rb
76
+ - lib/rouge/lexers/ini.rb
147
77
  - lib/rouge/lexers/scss.rb
148
- - lib/rouge/lexers/sed.rb
78
+ - lib/rouge/lexers/javascript.rb
149
79
  - lib/rouge/lexers/shell.rb
150
- - lib/rouge/lexers/smalltalk.rb
80
+ - lib/rouge/lexers/erlang.rb
81
+ - lib/rouge/lexers/yaml.rb
82
+ - lib/rouge/lexers/make.rb
83
+ - lib/rouge/lexers/objective_c.rb
84
+ - lib/rouge/lexers/lua.rb
85
+ - lib/rouge/lexers/viml.rb
86
+ - lib/rouge/lexers/java.rb
87
+ - lib/rouge/lexers/common_lisp.rb
151
88
  - lib/rouge/lexers/sml.rb
89
+ - lib/rouge/lexers/scheme.rb
90
+ - lib/rouge/lexers/haml.rb
91
+ - lib/rouge/lexers/erb.rb
92
+ - lib/rouge/lexers/literate_haskell.rb
93
+ - lib/rouge/lexers/c.rb
94
+ - lib/rouge/lexers/gherkin/keywords.rb
95
+ - lib/rouge/lexers/io.rb
96
+ - lib/rouge/lexers/elixir.rb
97
+ - lib/rouge/lexers/lua/builtins.rb
98
+ - lib/rouge/lexers/go.rb
99
+ - lib/rouge/lexers/python.rb
100
+ - lib/rouge/lexers/cpp.rb
152
101
  - lib/rouge/lexers/sql.rb
153
- - lib/rouge/lexers/tcl.rb
154
- - lib/rouge/lexers/tex.rb
155
- - lib/rouge/lexers/toml.rb
156
- - lib/rouge/lexers/vb.rb
157
- - lib/rouge/lexers/viml.rb
158
- - lib/rouge/lexers/viml/keywords.rb
159
- - lib/rouge/lexers/xml.rb
160
- - lib/rouge/lexers/yaml.rb
161
- - lib/rouge/plugins/redcarpet.rb
162
- - lib/rouge/regex_lexer.rb
163
- - lib/rouge/template_lexer.rb
164
- - lib/rouge/text_analyzer.rb
165
- - lib/rouge/theme.rb
166
- - lib/rouge/themes/base16.rb
167
- - lib/rouge/themes/colorful.rb
168
- - lib/rouge/themes/github.rb
169
- - lib/rouge/themes/monokai.rb
170
- - lib/rouge/themes/thankful_eyes.rb
171
- - lib/rouge/token.rb
172
- - lib/rouge/util.rb
173
- - lib/rouge/version.rb
174
- - rouge.gemspec
102
+ - lib/rouge/lexers/haskell.rb
103
+ - lib/rouge/lexers/matlab.rb
104
+ - lib/rouge/lexers/matlab/builtins.rb
105
+ - lib/rouge/lexers/r.rb
106
+ - lib/rouge/lexers/markdown.rb
107
+ - lib/rouge/lexers/ocaml.rb
108
+ - lib/rouge/lexers/prolog.rb
109
+ - lib/rouge/lexers/conf.rb
110
+ - lib/rouge.rb
111
+ - bin/rougify
112
+ - lib/rouge/demos/erlang
113
+ - lib/rouge/demos/moonscript
114
+ - lib/rouge/demos/sass
115
+ - lib/rouge/demos/ruby
116
+ - lib/rouge/demos/factor
117
+ - lib/rouge/demos/smalltalk
118
+ - lib/rouge/demos/yaml
119
+ - lib/rouge/demos/handlebars
120
+ - lib/rouge/demos/tex
121
+ - lib/rouge/demos/racket
122
+ - lib/rouge/demos/elixir
123
+ - lib/rouge/demos/php
124
+ - lib/rouge/demos/tcl
125
+ - lib/rouge/demos/html
126
+ - lib/rouge/demos/shell
127
+ - lib/rouge/demos/perl
128
+ - lib/rouge/demos/prolog
129
+ - lib/rouge/demos/r
130
+ - lib/rouge/demos/scala
131
+ - lib/rouge/demos/viml
132
+ - lib/rouge/demos/haskell
133
+ - lib/rouge/demos/css
134
+ - lib/rouge/demos/conf
135
+ - lib/rouge/demos/haml
136
+ - lib/rouge/demos/literate_haskell
137
+ - lib/rouge/demos/io
138
+ - lib/rouge/demos/c
139
+ - lib/rouge/demos/scss
140
+ - lib/rouge/demos/llvm
141
+ - lib/rouge/demos/literate_coffeescript
142
+ - lib/rouge/demos/python
143
+ - lib/rouge/demos/make
144
+ - lib/rouge/demos/clojure
145
+ - lib/rouge/demos/java
146
+ - lib/rouge/demos/csharp
147
+ - lib/rouge/demos/go
148
+ - lib/rouge/demos/javascript
149
+ - lib/rouge/demos/sed
150
+ - lib/rouge/demos/common_lisp
151
+ - lib/rouge/demos/groovy
152
+ - lib/rouge/demos/sml
153
+ - lib/rouge/demos/nginx
154
+ - lib/rouge/demos/vb
155
+ - lib/rouge/demos/toml
156
+ - lib/rouge/demos/gherkin
157
+ - lib/rouge/demos/http
158
+ - lib/rouge/demos/rust
159
+ - lib/rouge/demos/json
160
+ - lib/rouge/demos/markdown
161
+ - lib/rouge/demos/plaintext
162
+ - lib/rouge/demos/xml
163
+ - lib/rouge/demos/lua
164
+ - lib/rouge/demos/erb
165
+ - lib/rouge/demos/cpp
166
+ - lib/rouge/demos/coffeescript
167
+ - lib/rouge/demos/objective_c
168
+ - lib/rouge/demos/sql
169
+ - lib/rouge/demos/puppet
170
+ - lib/rouge/demos/matlab
171
+ - lib/rouge/demos/ini
172
+ - lib/rouge/demos/ocaml
173
+ - lib/rouge/demos/scheme
174
+ - lib/rouge/demos/diff
175
175
  homepage: http://github.com/jayferd/rouge
176
176
  licenses:
177
177
  - MIT (see LICENSE file)
@@ -182,17 +182,17 @@ require_paths:
182
182
  - lib
183
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ">="
185
+ - - '>='
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ">="
190
+ - - '>='
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project: rouge
195
- rubygems_version: 2.2.0
195
+ rubygems_version: 2.0.14
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: A pure-ruby colorizer based on pygments