class Asciidoctor::SyntaxHighlighter::PrettifyAdapter

Public Class Methods

new(*args) click to toggle source
Calls superclass method Asciidoctor::SyntaxHighlighter::new
# File lib/asciidoctor/syntax_highlighter/prettify.rb, line 6
def initialize *args
  super
  @pre_class = 'prettyprint'
end

Public Instance Methods

docinfo(location, doc, opts) click to toggle source
# File lib/asciidoctor/syntax_highlighter/prettify.rb, line 20
def docinfo location, doc, opts
  base_url = doc.attr 'prettifydir', %(#{opts[:cdn_base_url]}/prettify/r298)
  if location == :head
    prettify_theme_url = ((prettify_theme = doc.attr 'prettify-theme', 'prettify').start_with? 'http://', 'https://') ? prettify_theme : %(#{base_url}/#{prettify_theme}.min.css)
    %(<link rel="stylesheet" href="#{prettify_theme_url}"#{opts[:self_closing_tag_slash]}>)
  else # :footer
    %(<script src="#{base_url}/run_prettify.min.js"></script>)
  end
end
docinfo?(location) click to toggle source
# File lib/asciidoctor/syntax_highlighter/prettify.rb, line 16
def docinfo? location
  true
end
format(node, lang, opts) click to toggle source
# File lib/asciidoctor/syntax_highlighter/prettify.rb, line 11
def format node, lang, opts
  opts[:transform] = proc {|pre| pre['class'] += %( #{(start = node.attr 'start') ? %[linenums:#{start}] : 'linenums'}) } if node.attr? 'linenums'
  super
end