summaryrefslogtreecommitdiff
path: root/docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb
blob: 206e3a639a6cff29e9b237bf0cf2d005d20f3b9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class ExtendedPygmentsSyntaxHighlighter < (Asciidoctor::SyntaxHighlighter.for 'pygments')
  register_for :pygments

  def docinfo location, doc, opts
    stylesheet = doc.attr 'pygments-stylesheet', './pygments.css'
    if opts[:linkcss]
      slash = opts[:self_closing_tag_slash]
      %(<link rel="stylesheet" href="#{stylesheet}"#{slash}>)
    else
      stylesheet = doc.normalize_system_path stylesheet
      %(<style>
#{doc.read_asset stylesheet, label: 'stylesheet', normalize: true}
</style>)
    end
  end
end