Class: Asciidoctor::SyntaxHighlighter::Base
- Inherits:
-
Object
- Object
- Asciidoctor::SyntaxHighlighter::Base
- Includes:
- Asciidoctor::SyntaxHighlighter
- Defined in:
- lib/asciidoctor/syntax_highlighter.rb
Direct Known Subclasses
CodeRayAdapter, HighlightJsAdapter, HtmlPipelineAdapter, PrettifyAdapter, PygmentsAdapter, RougeAdapter
Constant Summary
Constants included from DefaultFactory
Instance Attribute Summary
Attributes included from Asciidoctor::SyntaxHighlighter
Instance Method Summary collapse
Methods included from Asciidoctor::SyntaxHighlighter
#docinfo, #docinfo?, #highlight, #highlight?, #initialize, #write_stylesheet, #write_stylesheet?
Methods included from DefaultFactory
Methods included from Factory
Instance Method Details
#format(node, lang, opts) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/asciidoctor/syntax_highlighter.rb', line 230 def format node, lang, opts class_attr_val = opts[:nowrap] ? %(#{@pre_class} highlight nowrap) : %(#{@pre_class} highlight) if (transform = opts[:transform]) pre = { 'class' => class_attr_val } code = lang ? { 'data-lang' => lang } : {} transform[pre, code] %(<pre#{pre.map {|k, v| %[ #{k}="#{v}"] }.join}><code#{code.map {|k, v| %[ #{k}="#{v}"] }.join}>#{node.content}</code></pre>) else %(<pre class="#{class_attr_val}"><code#{lang ? %[ data-lang="#{lang}"] : ''}>#{node.content}</code></pre>) end end |