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
233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/asciidoctor/syntax_highlighter.rb', line 233 def format node, lang, opts class_attr_val = opts[:nowrap] ? %(#{@pre_class} highlight nowrap) : %(#{@pre_class} highlight) if (transform = opts[:transform]) transform[(pre = { 'class' => class_attr_val }), (code = lang ? { 'data-lang' => lang } : {})] # NOTE: make sure data-lang is the last attribute on the code tag to remain consistent with 1.5.x if (lang = code.delete 'data-lang') code['data-lang'] = lang end %(<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 |