wbzyl-rack-codehighlighter 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 5
2
+ :patch: 6
3
3
  :major: 0
4
4
  :minor: 1
@@ -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
- use Rack::Codehighlighter, :ultraviolet, :theme => 'dawn', :logging => true
12
- #use Rack::Codehighlighter, :prettify, :logging => true
12
+
13
+ use Rack::Codehighlighter, :ultraviolet, :theme => 'dawn', :logging => true, :pattern => '//pre'
14
+
13
15
  run Sinatra::Application
@@ -13,11 +13,11 @@ module Rack
13
13
  def initialize(app, highlighter = :coderay, opts = {})
14
14
  @app = app
15
15
  @highlighter = highlighter
16
-
17
- @opts = { :element => "//pre/code",
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
- node.parent.swap(send(@highlighter, s))
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
- logger = env['rack.errors']
62
+ logger = env['rack.errors']
59
63
  logger.write FORMAT % [
60
64
  env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-",
61
65
  @highlighter,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbzyl-rack-codehighlighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wlodek Bzyl