Class: Asciidoctor::SyntaxHighlighter::PrettifyAdapter
- Inherits:
-
Base
- Object
- Base
- Asciidoctor::SyntaxHighlighter::PrettifyAdapter
show all
- Defined in:
- lib/asciidoctor/syntax_highlighter/prettify.rb
Constant Summary
DefaultFactory::PROVIDED
Instance Attribute Summary
#name
Instance Method Summary
collapse
#highlight, #highlight?, #write_stylesheet, #write_stylesheet?
#for, #register
Methods included from Factory
#create, #for, #register
Constructor Details
Returns a new instance of PrettifyAdapter.
6
7
8
9
|
# File 'lib/asciidoctor/syntax_highlighter/prettify.rb', line 6
def initialize *args
super
@pre_class = 'prettyprint'
end
|
Instance Method Details
#docinfo(location, doc, opts) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# 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 %(<script src="#{base_url}/run_prettify.min.js"></script>)
end
end
|
#docinfo?(location) ⇒ Boolean
16
17
18
|
# File 'lib/asciidoctor/syntax_highlighter/prettify.rb', line 16
def docinfo? location
true
end
|
11
12
13
14
|
# 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
|