diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2020-11-30 18:21:31 -0700 |
|---|---|---|
| committer | Sarah White <graphitefriction@gmail.com> | 2020-12-08 14:32:53 -0700 |
| commit | b5af8e2d8d66d24d9ac03d2bbfac66c74872ac78 (patch) | |
| tree | 508c211abefab84e53530fe36549afdc6195c9df /docs/modules/extensions | |
| parent | 5f79e05fb9cc115e897a569de2eecbf35f962d33 (diff) | |
switch fenced code blocks to AsciiDoc source blocks and always set language
Diffstat (limited to 'docs/modules/extensions')
10 files changed, 71 insertions, 49 deletions
diff --git a/docs/modules/extensions/pages/block-macro-processor.adoc b/docs/modules/extensions/pages/block-macro-processor.adoc index df451c43..45ef1dc8 100644 --- a/docs/modules/extensions/pages/block-macro-processor.adoc +++ b/docs/modules/extensions/pages/block-macro-processor.adoc @@ -6,14 +6,16 @@ Create a block macro named `gist` for embedding a gist. == sample-with-gist-macro.adoc -``` +[source,asciidoc] +---- .My Gist gist::123456[] -``` +---- == GistBlockMacro -```ruby +[source,ruby] +---- require 'asciidoctor' require 'asciidoctor/extensions' @@ -35,14 +37,15 @@ class GistBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor create_pass_block parent, html, attrs, subs: nil end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do block_macro GistBlockMacro if document.basebackend? 'html' end Asciidoctor.convert_file 'sample-with-gist.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/block-processor.adoc b/docs/modules/extensions/pages/block-processor.adoc index d228642e..fb04cbca 100644 --- a/docs/modules/extensions/pages/block-processor.adoc +++ b/docs/modules/extensions/pages/block-processor.adoc @@ -6,14 +6,16 @@ Register a custom block style named `shout` that uppercases all the words and co == sample-with-shout-block.adoc -``` +[source,asciidoc] +---- [shout] The time is now. Get a move on. -``` +---- == ShoutBlock -```ruby +[source,ruby] +---- require 'asciidoctor' require 'asciidoctor/extensions' @@ -32,14 +34,15 @@ class ShoutBlock < Asciidoctor::Extensions::BlockProcessor create_paragraph parent, (reader.lines.map {|l| l.upcase.gsub PeriodRx, '!' * volume }), attrs end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do block ShoutBlock end Asciidoctor.convert_file 'sample-with-shout-block.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/compound-block-processor.adoc b/docs/modules/extensions/pages/compound-block-processor.adoc index 32dea0e4..cd88a3b6 100644 --- a/docs/modules/extensions/pages/compound-block-processor.adoc +++ b/docs/modules/extensions/pages/compound-block-processor.adoc @@ -9,7 +9,7 @@ Register a custom block named `collapsible` that transforms a listing block into * the listing block is promoted to a source block if a language is specified using the second positional attribute. .sample-with-collapsible-block.adoc -[source] +[source,asciidoc] .... .Show JSON [collapsible,json] diff --git a/docs/modules/extensions/pages/docinfo-processor.adoc b/docs/modules/extensions/pages/docinfo-processor.adoc index d5510c1a..084937e3 100644 --- a/docs/modules/extensions/pages/docinfo-processor.adoc +++ b/docs/modules/extensions/pages/docinfo-processor.adoc @@ -6,7 +6,8 @@ Appends the Google Analytics tracking code to the bottom of an HTML document. == GoogleAnalyticsDocinfoProcessor -```ruby +[source,ruby] +---- class GoogleAnalyticsDocinfoProcessor < Asciidoctor::Extensions::DocinfoProcessor use_dsl at_location :footer @@ -22,15 +23,16 @@ ga('send','pageview'); </script>) end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do docinfo_processor GoogleAnalyticsDocinfoProcessor end Asciidoctor.convert_file 'sample.adoc', :safe => :safe, :attributes => 'UA-ABCXYZ123' -``` +---- diff --git a/docs/modules/extensions/pages/include-processor.adoc b/docs/modules/extensions/pages/include-processor.adoc index 8dbdd8e0..be27729a 100644 --- a/docs/modules/extensions/pages/include-processor.adoc +++ b/docs/modules/extensions/pages/include-processor.adoc @@ -8,7 +8,8 @@ TIP: Asciidoctor supports including content from a URI out of the box if you set == sample-with-uri-include.adoc -``` +[source,asciidoc] +.... :source-highlighter: coderay .Gemfile @@ -16,11 +17,12 @@ TIP: Asciidoctor supports including content from a URI out of the box if you set ---- \include::https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/Gemfile[] ---- -``` +.... == UriIncludeProcessor -```ruby +[source,ruby] +---- require 'asciidoctor' require 'asciidoctor/extensions' require 'open-uri' @@ -36,14 +38,15 @@ class UriIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor reader end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do include_processor UriIncludeProcessor end Asciidoctor.convert_file 'sample-with-uri-include.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/inline-macro-processor.adoc b/docs/modules/extensions/pages/inline-macro-processor.adoc index b8d88b0e..69a8b89e 100644 --- a/docs/modules/extensions/pages/inline-macro-processor.adoc +++ b/docs/modules/extensions/pages/inline-macro-processor.adoc @@ -6,13 +6,15 @@ Create an inline macro named `man` that links to a manpage. == sample-with-man-link.adoc -``` +[source,asciidoc] +---- See man:gittutorial[7] to get started. -``` +---- == ManpageInlineMacro -```ruby +[source,ruby] +---- require 'asciidoctor' require 'asciidoctor/extensions' @@ -35,14 +37,15 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor %(#{(create_anchor parent, text, type: :link, target: target).convert}#{suffix}) end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do inline_macro ManInlineMacro end Asciidoctor.convert_file 'sample-with-man-link.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/postprocessor.adoc b/docs/modules/extensions/pages/postprocessor.adoc index 712706ea..61be2401 100644 --- a/docs/modules/extensions/pages/postprocessor.adoc +++ b/docs/modules/extensions/pages/postprocessor.adoc @@ -6,7 +6,8 @@ Insert copyright text in the footer. == CopyrightFooterPostprocessor -```ruby +[source,ruby] +---- class CopyrightFooterPostprocessor < Asciidoctor::Extensions::Postprocessor def process document, output content = (document.attr 'copyright') || 'Copyright Acme, Inc.' @@ -20,14 +21,15 @@ class CopyrightFooterPostprocessor < Asciidoctor::Extensions::Postprocessor output end end -``` +---- == Usage -``` +[source,ruby] +---- Asciidoctor::Extensions.register do postprocessor CopyrightFooterPostprocessor end Asciidoctor.convert_file 'sample-with-copyright-footer.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/preprocessor.adoc b/docs/modules/extensions/pages/preprocessor.adoc index c1e5a406..aa32516c 100644 --- a/docs/modules/extensions/pages/preprocessor.adoc +++ b/docs/modules/extensions/pages/preprocessor.adoc @@ -6,26 +6,27 @@ Skim off front matter from the top of the document that gets used by site genera == sample-with-front-matter.adoc -``` ---- +[source,asciidoc] +---- tags: [announcement, website] --- = Document Title content -[subs="attributes,specialcharacters"] +[subs=+attributes] .Captured front matter .... --- {front-matter} --- .... -``` +---- == FrontMatterPreprocessor -```ruby +[source,ruby] +---- require 'asciidoctor' require 'asciidoctor/extensions' @@ -53,14 +54,15 @@ class FrontMatterPreprocessor < Asciidoctor::Extensions::Preprocessor reader end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do preprocessor FrontMatterPreprocessor end Asciidoctor.convert_file 'sample-with-front-matter.adoc', :safe => :safe -``` +---- diff --git a/docs/modules/extensions/pages/register.adoc b/docs/modules/extensions/pages/register.adoc index 7e076ba1..468398ef 100644 --- a/docs/modules/extensions/pages/register.adoc +++ b/docs/modules/extensions/pages/register.adoc @@ -4,7 +4,8 @@ These extensions are registered per document using a callback that feels like a DSL: -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do |document| preprocessor FrontMatterPreprocessor tree_processor ShellSessionTreeProcessor @@ -15,7 +16,7 @@ Asciidoctor::Extensions.register do |document| inline_macro ManInlineMacro include_processor UriIncludeProcessor end -``` +---- CAUTION: Extension classes must be defined outside of the register block. Once an extension class is registered, it is frozen, preventing further modification. diff --git a/docs/modules/extensions/pages/tree-processor.adoc b/docs/modules/extensions/pages/tree-processor.adoc index 050737ed..00a66436 100644 --- a/docs/modules/extensions/pages/tree-processor.adoc +++ b/docs/modules/extensions/pages/tree-processor.adoc @@ -6,16 +6,18 @@ Detect literal blocks that contain shell commands, strip the prompt character an == sample-with-shell-session.adoc -``` +[source,asciidoc] +---- $ echo "Hello, World!" > Hello, World! $ gem install asciidoctor -``` +---- == ShellSessionTreeProcessor -```ruby +[source,ruby] +---- class ShellSessionTreeProcessor < Asciidoctor::Extensions::TreeProcessor def process document return unless document.blocks? @@ -53,17 +55,18 @@ class ShellSessionTreeProcessor < Asciidoctor::Extensions::TreeProcessor create_listing_block block.document, lines * EOL, attrs, subs: nil end end -``` +---- == Usage -```ruby +[source,ruby] +---- Asciidoctor::Extensions.register do tree_processor ShellSessionTreeProcessor end Asciidoctor.convert_file 'sample-with-shell-session.adoc', :safe => :safe -``` +---- //// In the example below the TreeProcessor examines the block contents looking for the `// (*)` suffix and rewrites the line so that Asciidoctor formats it appropriately. |
