rouge 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'pathname'
4
4
  ROOT_DIR = Pathname.new(__FILE__).dirname.parent
5
+ $:.push(ROOT_DIR.join('lib'))
5
6
  load ROOT_DIR.join('lib/rouge.rb')
6
7
  load ROOT_DIR.join('lib/rouge/cli.rb')
7
8
 
@@ -12,6 +12,7 @@ module Rouge
12
12
  def initialize(opts={})
13
13
  @css_class = opts[:css_class] || 'highlight'
14
14
  @line_numbers = opts.fetch(:line_numbers) { false }
15
+ @wrap = opts.fetch(:wrap, true)
15
16
  end
16
17
 
17
18
  # @yield the html output.
@@ -24,11 +25,11 @@ module Rouge
24
25
  end
25
26
 
26
27
  def stream_untableized(tokens, &b)
27
- yield "<pre class=#{@css_class.inspect}>"
28
+ yield "<pre class=#{@css_class.inspect}>" if @wrap
28
29
  tokens.each do |tok, val|
29
30
  span(tok, val, &b)
30
31
  end
31
- yield '</pre>'
32
+ yield '</pre>' if @wrap
32
33
  end
33
34
 
34
35
  def stream_tableized(tokens, &b)
@@ -48,7 +49,7 @@ module Rouge
48
49
  %<<div class="lineno">#{x+1}</div>>
49
50
  end.join
50
51
 
51
- yield "<pre class=#{@css_class.inspect}>"
52
+ yield "<pre class=#{@css_class.inspect}>" if @wrap
52
53
  yield "<table><tbody><tr>"
53
54
 
54
55
  # the "gl" class applies the style for Generic.Lineno
@@ -61,7 +62,7 @@ module Rouge
61
62
  yield '</td>'
62
63
 
63
64
  yield '</tr></tbody></table>'
64
- yield '</pre>'
65
+ yield '</pre>' if @wrap
65
66
  end
66
67
 
67
68
  private
@@ -195,7 +195,7 @@ module Rouge
195
195
  rule /url\(.*?\)/, 'Literal.String.Other'
196
196
  rule /#[0-9a-f]{1,6}/i, 'Literal.Number' # colors
197
197
  rule /#{number}(?:em|px|%|pt|pc|in|mm|m|ex|s)?\b/, 'Literal.Number'
198
- rule /[\[\]():\/.]/, 'Punctuation'
198
+ rule /[\[\]():\/.,]/, 'Punctuation'
199
199
  rule /"(\\\\|\\"|[^"])*"/, 'Literal.String.Single'
200
200
  rule /'(\\\\|\\'|[^'])*'/, 'Literal.String.Double'
201
201
  rule(identifier) do |m|
@@ -65,7 +65,7 @@ module Rouge
65
65
  state :php do
66
66
  rule /\?>/, 'Comment.Preproc', :pop!
67
67
  # heredocs
68
- rule /<<<('?)([a-z_]\w*)\1\n.*?\n\2;?\n/im, 'String'
68
+ rule /<<<('?)([a-z_]\w*)\1\n.*?\n\2;?\n/im, 'Literal.String.Heredoc'
69
69
  rule /\s+/, 'Text'
70
70
  rule /#.*?\n/, 'Comment.Single'
71
71
  rule %r(//.*?\n), 'Comment.Single'
@@ -136,7 +136,7 @@ module Rouge
136
136
  rule /[^\\{$"]+/, 'Literal.String.Double'
137
137
  rule /\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})/,
138
138
  'Literal.String.Escape'
139
- rule /\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?/
139
+ rule /\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?/, 'Name.Variable'
140
140
 
141
141
  lsi = 'Literal.String.Interpol'
142
142
  rule /\{\$\{/, lsi, :interp_double
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.3.6"
3
+ "0.3.7"
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.3.6
4
+ version: 0.3.7
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-05-27 00:00:00.000000000 Z
12
+ date: 2013-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime