hyperbolist-rack-codehighlighter 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +11 -0
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/lib/rack/codehighlighter.rb +16 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -12,6 +12,10 @@ It supports the most popular Ruby code highlighters of today:
|
|
12
12
|
* coderay
|
13
13
|
* syntax
|
14
14
|
|
15
|
+
As well as
|
16
|
+
|
17
|
+
* [Unofficial Pygments API](http://pygments.appspot.com/)
|
18
|
+
|
15
19
|
To ease testing it implements *censor* highlighter.
|
16
20
|
|
17
21
|
|
@@ -106,11 +110,18 @@ Ultraviolet:
|
|
106
110
|
use Rack::Codehighlighter, :ultraviolet, :theme => "dawn", :lines => false,
|
107
111
|
:element => "pre", :pattern => /\A:::(\w+)\s*(\n|
)/i, :logging => false
|
108
112
|
|
113
|
+
or
|
114
|
+
|
109
115
|
use Rack::Codehighlighter, :ultraviolet, :markdown => true,
|
110
116
|
:theme => "minimal_theme", :lines => false, :element => "pre>code",
|
111
117
|
:pattern => /\A:::([-_+\w]+)\s*(\n|
)/, :logging => false,
|
112
118
|
:themes => {"vibrant_ink" => ["ruby"], "upstream_sunburst" => ["objective-c", "java"]}
|
113
119
|
|
120
|
+
Unofficial Pygments API:
|
121
|
+
|
122
|
+
use Rack::Codehighlighter, :pygments_api, :element => "pre",
|
123
|
+
:pattern => /\A:::([-_+\w]+)\s*(\n|
)/, :logging => false
|
124
|
+
|
114
125
|
Syntax:
|
115
126
|
|
116
127
|
use Rack::Codehighlighter, :syntax,
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
Jeweler::Tasks.new do |gemspec|
|
6
6
|
gemspec.name = "hyperbolist-rack-codehighlighter"
|
7
7
|
gemspec.summary = "Rack Middleware for Code Highlighting."
|
8
|
-
gemspec.email = "hyperbolist@gmail.com"
|
8
|
+
gemspec.email = "hyperbolist@gmail.com"
|
9
9
|
gemspec.homepage = "http://github.com/hyperbolist/rack-codehighlighter"
|
10
10
|
gemspec.authors = ["Eric Sherman"]
|
11
11
|
gemspec.description = gemspec.summary
|
data/VERSION.yml
CHANGED
data/lib/rack/codehighlighter.rb
CHANGED
@@ -130,6 +130,22 @@ module Rack
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
def pygments_api(string)
|
134
|
+
require 'net/http'
|
135
|
+
require 'uri'
|
136
|
+
lang = 'unknown'
|
137
|
+
refs = @opts[:pattern].match(string) # extract language name
|
138
|
+
if refs
|
139
|
+
lang = refs[1]
|
140
|
+
str = unescape_html(string.sub(@opts[:pattern], ""))
|
141
|
+
req = Net::HTTP.post_form(URI.parse('http://pygments.appspot.com/'),
|
142
|
+
{'lang' => lang, 'code' => str})
|
143
|
+
"#{req.body}"
|
144
|
+
else
|
145
|
+
"<pre>#{string}</pre>"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
133
149
|
def ultraviolet(string)
|
134
150
|
opts = { :theme => 'dawn', :lines => false, :themes => {} }
|
135
151
|
opts.merge! @opts
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperbolist-rack-codehighlighter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sherman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-12 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|