Sha256: 84cdd548554a97ecc328380938a74a2f740f4b337ca9f35422513d2ececbb2c8
Contents?: true
Size: 968 Bytes
Versions: 12
Compression:
Stored size: 968 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 true end 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 end end
Version data entries
12 entries across 12 versions & 1 rubygems