wbzyl-rack-codehighlighter 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/examples/config.ru +4 -2
- data/lib/rack/codehighlighter.rb +10 -6
- metadata +1 -1
data/VERSION.yml
CHANGED
data/examples/config.ru
CHANGED
@@ -5,9 +5,11 @@
|
|
5
5
|
require 'app'
|
6
6
|
|
7
7
|
use Rack::Lint
|
8
|
+
#use Rack::Codehighlighter, :prettify, :logging => true
|
8
9
|
|
9
10
|
#use Rack::Codehighlighter, :coderay, :logging => true
|
10
11
|
#use Rack::Codehighlighter, :syntax, :logging => true
|
11
|
-
|
12
|
-
|
12
|
+
|
13
|
+
use Rack::Codehighlighter, :ultraviolet, :theme => 'dawn', :logging => true, :pattern => '//pre'
|
14
|
+
|
13
15
|
run Sinatra::Application
|
data/lib/rack/codehighlighter.rb
CHANGED
@@ -13,11 +13,11 @@ module Rack
|
|
13
13
|
def initialize(app, highlighter = :coderay, opts = {})
|
14
14
|
@app = app
|
15
15
|
@highlighter = highlighter
|
16
|
-
|
17
|
-
|
16
|
+
@opts = {
|
17
|
+
:element => "//pre",
|
18
18
|
:pattern => /\A:::(\w+)\s*\n/,
|
19
|
-
:reason => "[...ugly code removed...]"
|
20
|
-
|
19
|
+
:reason => "[...ugly code removed...]"
|
20
|
+
}
|
21
21
|
@opts.merge! opts
|
22
22
|
end
|
23
23
|
|
@@ -37,7 +37,11 @@ module Rack
|
|
37
37
|
nodes = doc.search(@opts[:element])
|
38
38
|
nodes.each do |node|
|
39
39
|
s = node.inner_html || "[++where is the code?++]"
|
40
|
-
|
40
|
+
if @opts[:remove_parent_element]
|
41
|
+
node.parent.swap(send(@highlighter, s))
|
42
|
+
else
|
43
|
+
node.swap(send(@highlighter, s))
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
43
47
|
body = doc.to_html
|
@@ -55,7 +59,7 @@ module Rack
|
|
55
59
|
def log(env, status, headers, began_at)
|
56
60
|
# lilith.local [coderay] text/html [26/may/2009 12:00:00] "GET / HTTP/1.1" 200 ? ?\n
|
57
61
|
now = Time.now
|
58
|
-
|
62
|
+
logger = env['rack.errors']
|
59
63
|
logger.write FORMAT % [
|
60
64
|
env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
|
61
65
|
@highlighter,
|