Sha256: be4329974ebf23b6b1ad7ee76c777b3af6eafafcc9f1ae0f0ca1a74c064fe974

Contents?: true

Size: 1022 Bytes

Versions: 14

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true
module Asciidoctor
class SyntaxHighlighter::HighlightJsAdapter < SyntaxHighlighter::Base
  register_for 'highlightjs', 'highlight.js'

  def initialize *args
    super
    @name = @pre_class = 'highlightjs'
  end

  def format node, lang, opts
    super node, lang, (opts.merge transform: proc {|_, code| code['class'] = %(language-#{lang || 'none'} hljs) } )
  end

  def docinfo? location
    location == :footer
  end

  def docinfo location, doc, opts
    base_url = doc.attr 'highlightjsdir', %(#{opts[:cdn_base_url]}/highlight.js/#{HIGHLIGHT_JS_VERSION})
    %(<link rel="stylesheet" href="#{base_url}/styles/#{doc.attr 'highlightjs-theme', 'github'}.min.css"#{opts[:self_closing_tag_slash]}>
<script src="#{base_url}/highlight.min.js"></script>
#{(doc.attr? 'highlightjs-languages') ? ((doc.attr 'highlightjs-languages').split ',').map {|lang| %[<script src="#{base_url}/languages/#{lang.lstrip}.min.js"></script>\n] }.join : ''}<script>hljs.initHighlighting()</script>)
  end
end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/syntax_highlighter/highlightjs.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.10 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.9 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.8 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.7 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.6 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.5 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.4 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.3 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.2 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.1 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.0 lib/asciidoctor/syntax_highlighter/highlightjs.rb
asciidoctor-2.0.0.rc.3 lib/asciidoctor/syntax_highlighter/highlightjs.rb