"Fossies" - the Fresh Open Source Software Archive

Member "asciidoctor-2.0.10/lib/asciidoctor/syntax_highlighter/prettify.rb" (1 Jun 2019, 918 Bytes) of package /linux/www/asciidoctor-2.0.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # frozen_string_literal: true
    2 module Asciidoctor
    3 class SyntaxHighlighter::PrettifyAdapter < SyntaxHighlighter::Base
    4   register_for 'prettify'
    5 
    6   def initialize *args
    7     super
    8     @pre_class = 'prettyprint'
    9   end
   10 
   11   def format node, lang, opts
   12     opts[:transform] = proc {|pre| pre['class'] += %( #{(start = node.attr 'start') ? %[linenums:#{start}] : 'linenums'}) } if node.attr? 'linenums'
   13     super
   14   end
   15 
   16   def docinfo? location
   17     location == :footer
   18   end
   19 
   20   def docinfo location, doc, opts
   21     base_url = doc.attr 'prettifydir', %(#{opts[:cdn_base_url]}/prettify/r298)
   22     prettify_theme_url = ((prettify_theme = doc.attr 'prettify-theme', 'prettify').start_with? 'http://', 'https://') ? prettify_theme : %(#{base_url}/#{prettify_theme}.min.css)
   23     %(<link rel="stylesheet" href="#{prettify_theme_url}"#{opts[:self_closing_tag_slash]}>
   24 <script src="#{base_url}/run_prettify.min.js"></script>)
   25   end
   26 end
   27 end