Class Asciidoctor::Extensions::Registry
In: lib/asciidoctor/extensions.rb
Parent: Object

Public: The primary entry point into the extension system.

Registry holds the extensions which have been registered and activated, has methods for registering or defining a processor and looks up extensions stored in the registry during parsing.

Methods

Attributes

document  [R]  Public: Returns the {Asciidoctor::Document} on which the extensions in this registry are being used.
groups  [R]  Public: Returns the Array of {Group} classes, instances and/or Procs that have been registered.

Public Class methods

Public Instance methods

Public: Activates all the global extension {Group}s and the extension {Group}s associated with this registry.

document - the {Asciidoctor::Document} on which the extensions are to be used.

Returns the instance of this [Registry].

Public: Registers a {BlockProcessor} with the extension registry to process the block content (i.e., delimited block or paragraph) in the AsciiDoc source annotated with the specified block name (i.e., style).

The BlockProcessor may be one of four types:

Unless the BlockProcessor is passed as the method block, it must be the first argument to this method. The second argument is the name (coersed to a Symbol) of the AsciiDoc block content (i.e., delimited block or paragraph) that this processor is registered to handle. If a block name is not passed as an argument, it gets read from the name property of the BlockProcessor instance. If a name still cannot be determined, an error is raised.

Examples

  # as a BlockProcessor subclass
  block ShoutBlock

  # as a BlockProcessor subclass with an explicit block name
  block ShoutBlock, :shout

  # as an instance of a BlockProcessor subclass
  block ShoutBlock.new

  # as an instance of a BlockProcessor subclass with an explicit block name
  block ShoutBlock.new, :shout

  # as a name of a BlockProcessor subclass
  block 'ShoutBlock'

  # as a name of a BlockProcessor subclass with an explicit block name
  block 'ShoutBlock', :shout

  # as a method block
  block do
    named :shout
    process |parent, reader, attrs|
      ...
    end
  end

  # as a method block with an explicit block name
  block :shout do
    process |parent, reader, attrs|
      ...
    end
  end

Returns an instance of the [Extension] proxy object that is stored in the registry and manages the instance of this BlockProcessor.

Public: Registers a {BlockMacroProcessor} with the extension registry to process a block macro with the specified name.

The BlockMacroProcessor may be one of four types:

Unless the BlockMacroProcessor is passed as the method block, it must be the first argument to this method. The second argument is the name (coersed to a Symbol) of the AsciiDoc block macro that this processor is registered to handle. If a block macro name is not passed as an argument, it gets read from the name property of the BlockMacroProcessor instance. If a name still cannot be determined, an error is raised.

Examples

  # as a BlockMacroProcessor subclass
  block_macro GistBlockMacro

  # as a BlockMacroProcessor subclass with an explicit macro name
  block_macro GistBlockMacro, :gist

  # as an instance of a BlockMacroProcessor subclass
  block_macro GistBlockMacro.new

  # as an instance of a BlockMacroProcessor subclass with an explicit macro name
  block_macro GistBlockMacro.new, :gist

  # as a name of a BlockMacroProcessor subclass
  block_macro 'GistBlockMacro'

  # as a name of a BlockMacroProcessor subclass with an explicit macro name
  block_macro 'GistBlockMacro', :gist

  # as a method block
  block_macro do
    named :gist
    process |parent, target, attrs|
      ...
    end
  end

  # as a method block with an explicit macro name
  block_macro :gist do
    process |parent, target, attrs|
      ...
    end
  end

Returns an instance of the [Extension] proxy object that is stored in the registry and manages the instance of this BlockMacroProcessor.

Public: Checks whether any {BlockMacroProcessor} extensions have been registered.

Returns a [Boolean] indicating whether any BlockMacroProcessor extensions are registered.

Public: Checks whether any {BlockProcessor} extensions have been registered.

Returns a [Boolean] indicating whether any BlockProcessor extensions are registered.

Public: Registers an {DocinfoProcessor} with the extension registry to add additionnal docinfo to the document.

The DocinfoProcessor may be one of four types:

Unless the DocinfoProcessor is passed as the method block, it must be the first argument to this method.

Examples

  # as an DocinfoProcessor subclass
  docinfo_processor MetaRobotsDocinfoProcessor

  # as an instance of a DocinfoProcessor subclass with an explicit location
  docinfo_processor JQueryDocinfoProcessor.new, :location => :footer

  # as a name of a DocinfoProcessor subclass
  docinfo_processor 'MetaRobotsDocinfoProcessor'

  # as a method block
  docinfo_processor do
    process |doc|
      at_location :footer
      'footer content'
    end
  end

Returns the [Extension] stored in the registry that proxies the instance of this DocinfoProcessor.

Public: Retrieves the {Extension} proxy objects for all the DocinfoProcessor instances stored in this registry.

location - A Symbol for selecting docinfo extensions at a given location (:head or :footer) (default: nil)

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {DocinfoProcessor} extensions have been registered.

location - A Symbol for selecting docinfo extensions at a given location (:head or :footer) (default: nil)

Returns a [Boolean] indicating whether any DocinfoProcessor extensions are registered.

Public: Retrieves the {Extension} proxy object for the BlockProcessor registered to handle block content with the name.

name - the String or Symbol (coersed to a Symbol) macro name

Returns the [Extension] object stored in the registry that proxies the corresponding BlockProcessor or nil if a match is not found.

Public: Retrieves the {Extension} proxy object for the BlockMacroProcessor registered to handle a block macro with the specified name.

name - the String or Symbol (coersed to a Symbol) macro name

Returns the [Extension] object stored in the registry that proxies the cooresponding BlockMacroProcessor or nil if a match is not found.

Public: Retrieves the {Extension} proxy object for the InlineMacroProcessor registered to handle an inline macro with the specified name.

name - the String or Symbol (coersed to a Symbol) macro name

Returns the [Extension] object stored in the registry that proxies the cooresponding InlineMacroProcessor or nil if a match is not found.

Public: Registers an {IncludeProcessor} with the extension registry to have a shot at handling the include directive.

The IncludeProcessor may be one of four types:

Unless the IncludeProcessor is passed as the method block, it must be the first argument to this method.

Examples

  # as an IncludeProcessor subclass
  include_processor GitIncludeProcessor

  # as an instance of a Postprocessor subclass
  include_processor GitIncludeProcessor.new

  # as a name of a Postprocessor subclass
  include_processor 'GitIncludeProcessor'

  # as a method block
  include_processor do
    process |document, output|
      ...
    end
  end

Returns the [Extension] stored in the registry that proxies the instance of this IncludeProcessor.

Public: Retrieves the {Extension} proxy objects for all the IncludeProcessor instances stored in this registry.

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {IncludeProcessor} extensions have been registered.

Returns a [Boolean] indicating whether any IncludeProcessor extensions are registered.

Public: Registers a {InlineMacroProcessor} with the extension registry to process an inline macro with the specified name.

The InlineMacroProcessor may be one of four types:

Unless the InlineMacroProcessor is passed as the method block, it must be the first argument to this method. The second argument is the name (coersed to a Symbol) of the AsciiDoc block macro that this processor is registered to handle. If a block macro name is not passed as an argument, it gets read from the name property of the InlineMacroProcessor instance. If a name still cannot be determined, an error is raised.

Examples

  # as an InlineMacroProcessor subclass
  inline_macro ChromeInlineMacro

  # as an InlineMacroProcessor subclass with an explicit macro name
  inline_macro ChromeInineMacro, :chrome

  # as an instance of an InlineMacroProcessor subclass
  inline_macro ChromeInlineMacro.new

  # as an instance of an InlineMacroProcessor subclass with an explicit macro name
  inline_macro ChromeInlineMacro.new, :chrome

  # as a name of an InlineMacroProcessor subclass
  inline_macro 'ChromeInlineMacro'

  # as a name of an InlineMacroProcessor subclass with an explicit macro name
  inline_macro 'ChromeInineMacro', :chrome

  # as a method block
  inline_macro do
    named :chrome
    process |parent, target, attrs|
      ...
    end
  end

  # as a method block with an explicit macro name
  inline_macro :chrome do
    process |parent, target, attrs|
      ...
    end
  end

Returns an instance of the [Extension] proxy object that is stored in the registry and manages the instance of this InlineMacroProcessor.

Public: Retrieves the {Extension} proxy objects for all InlineMacroProcessor instances in this registry.

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {InlineMacroProcessor} extensions have been registered.

Returns a [Boolean] indicating whether any IncludeMacroProcessor extensions are registered.

Public: Registers a {Postprocessor} with the extension registry to process the output after conversion is complete.

The Postprocessor may be one of four types:

Unless the Postprocessor is passed as the method block, it must be the first argument to this method.

Examples

  # as a Postprocessor subclass
  postprocessor AnalyticsPostprocessor

  # as an instance of a Postprocessor subclass
  postprocessor AnalyticsPostprocessor.new

  # as a name of a Postprocessor subclass
  postprocessor 'AnalyticsPostprocessor'

  # as a method block
  postprocessor do
    process |document, output|
      ...
    end
  end

Returns the [Extension] stored in the registry that proxies the instance of this Postprocessor.

Public: Retrieves the {Extension} proxy objects for all Postprocessor instances in this registry.

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {Postprocessor} extensions have been registered.

Returns a [Boolean] indicating whether any Postprocessor extensions are registered.

Public: Registers a {Preprocessor} with the extension registry to process the AsciiDoc source before parsing begins.

The Preprocessor may be one of four types:

Unless the Preprocessor is passed as the method block, it must be the first argument to this method.

Examples

  # as a Preprocessor subclass
  preprocessor FrontMatterPreprocessor

  # as an instance of a Preprocessor subclass
  preprocessor FrontMatterPreprocessor.new

  # as a name of a Preprocessor subclass
  preprocessor 'FrontMatterPreprocessor'

  # as a method block
  preprocessor do
    process |reader, lines|
      ...
    end
  end

Returns the [Extension] stored in the registry that proxies the instance of this Preprocessor.

Public: Retrieves the {Extension} proxy objects for all Preprocessor instances in this registry.

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {Preprocessor} extensions have been registered.

Returns a [Boolean] indicating whether any Preprocessor extensions are registered.

Public: Checks whether any {BlockProcessor} extensions are registered to handle the specified block name appearing on the specified context.

Returns the [Extension] proxy object for the BlockProcessor that matches the block name and context or false if no match is found.

Public: Checks whether any {BlockMacroProcessor} extensions are registered to handle the block macro with the specified name.

name - the String or Symbol (coersed to a Symbol) macro name

Returns the [Extension] proxy object for the BlockMacroProcessor that matches the macro name or false if no match is found.

Public: Checks whether any {InlineMacroProcessor} extensions are registered to handle the inline macro with the specified name.

name - the String or Symbol (coersed to a Symbol) macro name

Returns the [Extension] proxy object for the InlineMacroProcessor that matches the macro name or false if no match is found.

Public: Registers a {Treeprocessor} with the extension registry to process the AsciiDoc source after parsing is complete.

The Treeprocessor may be one of four types:

Unless the Treeprocessor is passed as the method block, it must be the first argument to this method.

Examples

  # as a Treeprocessor subclass
  treeprocessor ShellTreeprocessor

  # as an instance of a Treeprocessor subclass
  treeprocessor ShellTreeprocessor.new

  # as a name of a Treeprocessor subclass
  treeprocessor 'ShellTreeprocessor'

  # as a method block
  treeprocessor do
    process |document|
      ...
    end
  end

Returns the [Extension] stored in the registry that proxies the instance of this Treeprocessor.

Public: Retrieves the {Extension} proxy objects for all Treeprocessor instances in this registry.

Returns an [Array] of Extension proxy objects.

Public: Checks whether any {Treeprocessor} extensions have been registered.

Returns a [Boolean] indicating whether any Treeprocessor extensions are registered.

[Validate]