Sha256: 08c091c2cf21a107c37e299e6cdd624ac21bbb968a0f93c86a8624aa99a2e4a5

Contents?: true

Size: 918 Bytes

Versions: 16

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true
module Asciidoctor
class SyntaxHighlighter::PrettifyAdapter < SyntaxHighlighter::Base
  register_for 'prettify'

  def initialize *args
    super
    @pre_class = 'prettyprint'
  end

  def format node, lang, opts
    opts[:transform] = proc {|pre| pre['class'] += %( #{(start = node.attr 'start') ? %[linenums:#{start}] : 'linenums'}) } if node.attr? 'linenums'
    super
  end

  def docinfo? location
    location == :footer
  end

  def docinfo location, doc, opts
    base_url = doc.attr 'prettifydir', %(#{opts[:cdn_base_url]}/prettify/r298)
    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]}>
<script src="#{base_url}/run_prettify.min.js"></script>)
  end
end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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