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 +1 -0
- data/README.md +10 -1
- data/lib/rack/highlighter.rb +6 -0
- data/lib/rack/highlighter/version.rb +1 -1
- data/rack-highlighter.gemspec +1 -0
- data/spec/highlighter_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- metadata +19 -6
data/.travis.yml
CHANGED
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
|
data/lib/rack/highlighter.rb
CHANGED
@@ -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
|
data/rack-highlighter.gemspec
CHANGED
@@ -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'
|
data/spec/highlighter_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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.
|
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:
|
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.
|
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,
|