Sha256: 2e90bcae60bba178b795f1473e1caa1357626b65384071b18203ef4a8509a745

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

module Slippery
  module Processors
    class AddHighlight
      include ProcessorHelpers

      DEFAULT_STYLE   = :default
      DEFAULT_VERSION = '8.0'

      def initialize(style = DEFAULT_STYLE, version = DEFAULT_VERSION)
        @style = style
        @version = version
      end

      def call(doc)
        # css = "http://yandex.st/highlightjs/#{@version}/styles/#{@style}.min.css"
        # js  = "http://yandex.st/highlightjs/#{@version}/highlight.min.js"

        js = asset_uri('highlight.js/highlight.pack.js')
        css = asset_uri('highlight.js/highlight-0.8.default.min.css')

        doc.rewrite 'head' do |head|
          head <<= H[:link, rel: "stylesheet", href: css]
          head <<= H[:script, src: js]
          head <<= H[:script, 'hljs.initHighlightingOnLoad();']
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slippery-0.4.1 lib/slippery/processors/add_highlight.rb
slippery-0.4.0 lib/slippery/processors/add_highlight.rb