Sha256: 8226ac828e24981dd3f67b1f20027a0800c9f8d85271cd0cb50b2646ca482200

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module Slippery
  module Processors
    class AddHighlight
      include ProcessorHelpers

      DEFAULT_STYLE = :default

      def initialize(style = DEFAULT_STYLE)
        @style = style
      end

      def call(doc)
        js = asset_uri('highlight.js/highlight.pack.js')
        css = asset_uri("highlight.js/styles/#{@style}.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

1 entries across 1 versions & 1 rubygems

Version Path
slippery-0.4.2 lib/slippery/processors/add_highlight.rb