Class: Slippery::Processors::AddHighlight

Inherits:
Object
  • Object
show all
Defined in:
lib/slippery/processors/add_highlight.rb

Constant Summary collapse

DEFAULT_STYLE =
:default
DEFAULT_VERSION =
'8.0'

Instance Method Summary collapse

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