hyperbolist-rack-codehighlighter 0.4.2 → 0.4.3
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/README.markdown +5 -0
- data/VERSION.yml +1 -1
- data/lib/rack/codehighlighter.rb +4 -2
- metadata +1 -1
data/README.markdown
CHANGED
@@ -106,6 +106,11 @@ Ultraviolet:
|
|
106
106
|
use Rack::Codehighlighter, :ultraviolet, :theme => "dawn", :lines => false,
|
107
107
|
:element => "pre", :pattern => /\A:::(\w+)\s*(\n|
)/i, :logging => false
|
108
108
|
|
109
|
+
use Rack::Codehighlighter, :ultraviolet, :markdown => true,
|
110
|
+
:theme => "minimal_theme", :lines => false, :element => "pre>code",
|
111
|
+
:pattern => /\A:::([-_+\w]+)\s*(\n|
)/, :logging => false,
|
112
|
+
:themes => {"vibrant_ink" => ["ruby"], "upstream_sunburst" => ["objective-c", "java"]}
|
113
|
+
|
109
114
|
Syntax:
|
110
115
|
|
111
116
|
use Rack::Codehighlighter, :syntax,
|
data/VERSION.yml
CHANGED
data/lib/rack/codehighlighter.rb
CHANGED
@@ -131,14 +131,16 @@ module Rack
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def ultraviolet(string)
|
134
|
-
opts = { :theme => 'dawn', :lines => false }
|
134
|
+
opts = { :theme => 'dawn', :lines => false, :themes => {} }
|
135
135
|
opts.merge! @opts
|
136
136
|
lang = 'text'
|
137
137
|
refs = @opts[:pattern].match(string) # extract language name
|
138
138
|
if refs
|
139
139
|
lang = refs[1]
|
140
|
+
theme = opts[:themes].collect do |k,v|
|
141
|
+
k if v.include? lang end.compact.first || opts[:theme]
|
140
142
|
str = unescape_html(string.sub(@opts[:pattern], ""))
|
141
|
-
"#{::Uv.parse(str, 'xhtml', lang, opts[:lines],
|
143
|
+
"#{::Uv.parse(str, 'xhtml', lang, opts[:lines], theme)}"
|
142
144
|
else
|
143
145
|
"<pre class='#{opts[:theme]}'>#{string}</pre>"
|
144
146
|
end
|