class Asciidoctor::SyntaxHighlighter::HighlightJsAdapter
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Asciidoctor::SyntaxHighlighter::new
# File lib/asciidoctor/syntax_highlighter/highlightjs.rb, line 6 def initialize *args super @name = @pre_class = 'highlightjs' end
Public Instance Methods
docinfo(location, doc, opts)
click to toggle source
# File lib/asciidoctor/syntax_highlighter/highlightjs.rb, line 19 def docinfo location, doc, opts base_url = doc.attr 'highlightjsdir', %(#{opts[:cdn_base_url]}/highlight.js/#{HIGHLIGHT_JS_VERSION}) if location == :head %(<link rel="stylesheet" href="#{base_url}/styles/#{doc.attr 'highlightjs-theme', 'github'}.min.css"#{opts[:self_closing_tag_slash]}>) else # :footer %(<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> if (!hljs.initHighlighting.called) { hljs.initHighlighting.called = true ;[].slice.call(document.querySelectorAll('pre.highlight > code[data-lang]')).forEach(function (el) { hljs.highlightBlock(el) }) } </script>) end end
docinfo?(location)
click to toggle source
# File lib/asciidoctor/syntax_highlighter/highlightjs.rb, line 15 def docinfo? location true end
format(node, lang, opts)
click to toggle source
Calls superclass method
Asciidoctor::SyntaxHighlighter::Base#format
# File lib/asciidoctor/syntax_highlighter/highlightjs.rb, line 11 def format node, lang, opts super node, lang, (opts.merge transform: proc {|_, code| code['class'] = %(language-#{lang || 'none'} hljs) }) end