rack-highlighter 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,4 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - ruby-head
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rack::Highlighter [![Build Status](https://secure.travis-ci.org/unindented/rack-highlighter.png)](http://travis-ci.org/unindented/rack-highlighter)
2
2
 
3
- Rack Middleware that provides syntax highlighting of code blocks, using the [CodeRay](http://rubygems.org/gems/coderay), [Pygments](http://rubygems.org/gems/pygments.rb) or [Ultraviolet](http://rubygems.org/gems/ultraviolet) gems.
3
+ Rack Middleware that provides syntax highlighting of code blocks, using the [CodeRay](http://rubygems.org/gems/coderay), [Pygments](http://rubygems.org/gems/pygments.rb), [Rouge](https://rubygems.org/gems/rouge) or [Ultraviolet](http://rubygems.org/gems/ultraviolet) gems.
4
4
 
5
5
 
6
6
  ## Installation
@@ -88,6 +88,15 @@ require 'pygments'
88
88
  use Rack::Highlighter, :pygments
89
89
  ```
90
90
 
91
+ ### Rouge
92
+
93
+ ```ruby
94
+ require 'rack/highlighter'
95
+ require 'rouge'
96
+
97
+ use Rack::Highlighter, :rouge
98
+ ```
99
+
91
100
  ### Ultraviolet
92
101
 
93
102
  ```ruby
@@ -89,6 +89,12 @@ module Rack
89
89
  Pygments.highlight(code, formatter: 'html', lexer: lang, options: options)
90
90
  end
91
91
 
92
+ def rouge(lang, code, options)
93
+ lexer = Rouge::Lexer.find_fancy(lang, code) || Rouge::Lexers::Text
94
+ formatter = Rouge::Formatters::HTML.new(options)
95
+ formatter.format(lexer.lex(code))
96
+ end
97
+
92
98
  def ultraviolet(lang, code, options)
93
99
  Uv.parse(code, 'xhtml', lang, options[:lines], options[:theme])
94
100
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Highlighter
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -26,6 +26,7 @@ Gem::Specification.new do |gem|
26
26
 
27
27
  gem.add_development_dependency 'coderay', '~> 1.0'
28
28
  gem.add_development_dependency 'pygments.rb', '~> 0.3'
29
+ gem.add_development_dependency 'rouge', '~> 0.3'
29
30
  gem.add_development_dependency 'ultraviolet', '~> 1.0'
30
31
 
31
32
  gem.add_development_dependency 'rake'
@@ -3,6 +3,7 @@ require File.expand_path('../spec_helper', __FILE__)
3
3
  HIGHLIGHTERS = [
4
4
  :coderay,
5
5
  :pygments,
6
+ :rouge,
6
7
  :ultraviolet
7
8
  ]
8
9
 
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'rack/test'
4
4
 
5
5
  require 'coderay'
6
6
  require 'pygments'
7
+ require 'rouge'
7
8
  require 'uv'
8
9
 
9
10
  require File.expand_path('../../lib/rack/highlighter', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-highlighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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: 2012-12-23 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0.3'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rouge
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '0.3'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '0.3'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: ultraviolet
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -272,12 +288,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
288
  - - ! '>='
273
289
  - !ruby/object:Gem::Version
274
290
  version: '0'
275
- segments:
276
- - 0
277
- hash: -1336533414819540878
278
291
  requirements: []
279
292
  rubyforge_project:
280
- rubygems_version: 1.8.23
293
+ rubygems_version: 1.8.25
281
294
  signing_key:
282
295
  specification_version: 3
283
296
  summary: Rack Middleware that provides syntax highlighting of code blocks, using CodeRay,