summaryrefslogtreecommitdiff
path: root/docs/modules/syntax-highlighting/examples
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2020-11-24 17:49:00 -0700
committerSarah White <graphitefriction@gmail.com>2020-12-08 14:32:53 -0700
commitbab6916f2a8cf7bf3791c08e90aee02dee7a7725 (patch)
treedb52e8337ea3a7eecd41d3a7a5f22471f2a89ba3 /docs/modules/syntax-highlighting/examples
parentf096ff14e7aa881d0bb797e481ae2b66daccdebd (diff)
write intro for Syntax Highlighting; document how to create a custom adapter
- explain what source highlighting is - explain difference between client-side and build-time syntax highlighter - rework table that summarizes built-in syntax highlighters - clarify that Asciidoctor does not apply syntax highlighting when producing DocBook - add page about how to create a custom adapter
Diffstat (limited to 'docs/modules/syntax-highlighting/examples')
-rw-r--r--docs/modules/syntax-highlighting/examples/syntax-highlighter-prism.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/docs/modules/syntax-highlighting/examples/syntax-highlighter-prism.rb b/docs/modules/syntax-highlighting/examples/syntax-highlighter-prism.rb
new file mode 100644
index 00000000..8233c83e
--- /dev/null
+++ b/docs/modules/syntax-highlighting/examples/syntax-highlighter-prism.rb
@@ -0,0 +1,25 @@
+class PrismSyntaxHighlighter < Asciidoctor::SyntaxHighlighter::Base
+ register_for 'prism'
+
+ def format node, lang, opts
+ opts[:transform] = proc do |pre, code|
+ code['class'] = %(language-#{lang}) if lang
+ end
+ super
+ end
+
+ def docinfo? location
+ location == :footer
+ end
+
+ def docinfo location, doc, opts
+ base_url = doc.attr 'prismdir', %(#{opts[:cdn_base_url]}/prism/1.15.0)
+ slash = opts[:self_closing_tag_slash]
+ unless (theme_name = doc.attr 'prism-style', 'prism') == 'prism'
+ theme_name = %(prism-#{theme_name})
+ end
+ %(<link rel="stylesheet" href="#{base_url}/themes/#{theme_name}.min.css"#{slash}>
+<script src="#{base_url}/prism.min.js"></script>
+<script src="#{base_url}/components/prism-ruby.min.js"></script>)
+ end
+end