summaryrefslogtreecommitdiff
path: root/docs/modules/syntax-highlighting/examples
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-12-23 23:59:06 -0700
committerDan Allen <dan.j.allen@gmail.com>2021-12-24 00:10:28 -0700
commitaf604e90b95e2bcabf772896d994647277b81464 (patch)
tree28318f4bc78a9587f4ec312e30da75ceb3dd7fc8 /docs/modules/syntax-highlighting/examples
parent40fc0fe353ebd45eea3751356c4760758ebeabcf (diff)
fix syntax highlighter example to fully support pygments-stylesheet attribute
Diffstat (limited to 'docs/modules/syntax-highlighting/examples')
-rw-r--r--docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb b/docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb
index 9c6fdae1..ef32705e 100644
--- a/docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb
+++ b/docs/modules/syntax-highlighting/examples/pygments-syntax-highlighter-with-custom-stylesheet.rb
@@ -1,12 +1,15 @@
-class MyPygmentsAdapter < (Asciidoctor::SyntaxHighlighter.for 'pygments')
+class ExtendedPygmentsSyntaxHighlighter < (Asciidoctor::SyntaxHighlighter.for 'pygments')
register_for :pygments
- def write_stylesheet? doc
- false
- end
-
def docinfo location, doc, opts
- slash = opts[:self_closing_tag_slash]
- %(<link rel="stylesheet" href="/styles/syntax-theme.css"#{slash}>)
+ stylesheet = doc.attr 'pygments-stylesheet', './pygments.css'
+ if opts[:linkcss]
+ %(<link rel="stylesheet" href="#{stylesheet}"#{opts[:self_closing_tag_slash]}>)
+ else
+ stylesheet = doc.normalize_system_path stylesheet
+ %(<style>
+#{doc.read_asset stylesheet, label: 'stylesheet', normalize: true}
+</style>)
+ end
end
end