Class: Slippery::Processors::AddHighlight
- Inherits:
-
Object
- Object
- Slippery::Processors::AddHighlight
- Defined in:
- lib/slippery/processors/add_highlight.rb
Constant Summary collapse
- DEFAULT_STYLE =
:default
- DEFAULT_VERSION =
'8.0'
Instance Method Summary collapse
- #call(doc) ⇒ Object
-
#initialize(style = DEFAULT_STYLE, version = DEFAULT_VERSION) ⇒ AddHighlight
constructor
A new instance of AddHighlight.
Constructor Details
#initialize(style = DEFAULT_STYLE, version = DEFAULT_VERSION) ⇒ AddHighlight
Returns a new instance of AddHighlight.
8 9 10 11 |
# File 'lib/slippery/processors/add_highlight.rb', line 8 def initialize(style = DEFAULT_STYLE, version = DEFAULT_VERSION) @style = style @version = version end |
Instance Method Details
#call(doc) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/slippery/processors/add_highlight.rb', line 13 def call(doc) doc.rewrite 'head' do |head| head <<= H[:link, rel: "stylesheet", href: "http://yandex.st/highlightjs/#{@version}/styles/#{@style}.min.css"] head <<= H[:script, src: "http://yandex.st/highlightjs/#{@version}/highlight.min.js"] head <<= H[:script, 'hljs.initHighlightingOnLoad();'] end end |