"Fossies" - the Fresh Open Source Software Archive

Member "asciidoctor-2.0.10/lib/asciidoctor/syntax_highlighter/highlightjs.rb" (1 Jun 2019, 1022 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::HighlightJsAdapter < SyntaxHighlighter::Base
    4   register_for 'highlightjs', 'highlight.js'
    5 
    6   def initialize *args
    7     super
    8     @name = @pre_class = 'highlightjs'
    9   end
   10 
   11   def format node, lang, opts
   12     super node, lang, (opts.merge transform: proc {|_, code| code['class'] = %(language-#{lang || 'none'} hljs) } )
   13   end
   14 
   15   def docinfo? location
   16     location == :footer
   17   end
   18 
   19   def docinfo location, doc, opts
   20     base_url = doc.attr 'highlightjsdir', %(#{opts[:cdn_base_url]}/highlight.js/#{HIGHLIGHT_JS_VERSION})
   21     %(<link rel="stylesheet" href="#{base_url}/styles/#{doc.attr 'highlightjs-theme', 'github'}.min.css"#{opts[:self_closing_tag_slash]}>
   22 <script src="#{base_url}/highlight.min.js"></script>
   23 #{(doc.attr? 'highlightjs-languages') ? ((doc.attr 'highlightjs-languages').split ',').map {|lang| %[<script src="#{base_url}/languages/#{lang.lstrip}.min.js"></script>\n] }.join : ''}<script>hljs.initHighlighting()</script>)
   24   end
   25 end
   26 end