Module Asciidoctor::Substituters
In: lib/asciidoctor/substituters.rb

Public: Methods to perform substitutions on lines of AsciiDoc text. This module is intented to be mixed-in to Section and Block to provide operations for performing the necessary substitutions.

Methods

Constants

COMPOSITE_SUBS = { :none => [], :normal => [:specialcharacters, :quotes, :attributes, :replacements, :macros, :post_replacements], :verbatim => [:specialcharacters, :callouts]
SUB_OPTIONS = COMPOSITE_SUBS.keys + COMPOSITE_SUBS[:normal]

Attributes

passthroughs  [R]  Internal: A String Array of passthough (unprocessed) text captured from this block

Public Instance methods

Public: Apply substitutions for header metadata and attribute assignments

text - String containing the text process

returns - A String with header substitutions performed

Public: Apply substitutions for titles

lines - A String Array containing the lines of text process

returns - A String with literal (verbatim) substitutions performed

Public: Apply normal substitutions.

lines - The lines of text to process. Can be a String or a String Array

returns - A String with normal substitutions performed

Public: Apply explicit substitutions, if specified, otherwise normal substitutions.

lines - The lines of text to process. Can be a String or a String Array

returns - A String with substitutions applied

Public: Apply substitutions for passthrough text

lines - A String Array containing the lines of text process

returns - A String with passthrough substitutions performed

Public: Apply the specified substitutions to the lines of text

lines - The lines of text to process. Can be a String or a String Array subs - The substitutions to perform. Can be a Symbol or a Symbol Array (default: COMPOSITE_SUBS[:normal])

returns Either a String or String Array, whichever matches the type of the first argument

Public: Apply substitutions for titles.

title - The String title to process

returns - A String with title substitutions performed

Internal: Extract the passthrough text from the document for reinsertion after processing.

text - The String from which to extract passthrough fragements

returns - The text with the passthrough region substituted with placeholders

Public: Highlight the source code if a source highlighter is defined on the document, otherwise return the text unprocessed

source - the source code String to highlight

returns the highlighted source code, if a source highlighter is defined on the document, otherwise the unprocessed text

Internal: Parse the attributes in the attribute line

attrline - A String of unprocessed attributes (key/value pairs) posattrs - The keys for positional attributes

returns nil if attrline is nil, an empty Hash if attrline is empty, otherwise a Hash of parsed attributes

Internal: Resolve the list of comma-delimited subs against the possible options.

subs - A comma-delimited String of substitution aliases

returns An Array of Symbols representing the substitution operation

Internal: Restore the passthrough text by reinserting into the placeholder positions

text - The String text into which to restore the passthrough text

returns The String text with the passthrough text restored

Public: Substitute attribute references

Attribute references are in the format {name}.

If an attribute referenced in the line is missing, the line is dropped.

text - The String text to process

returns The String text with the attribute references replaced with attribute values

Public: Substitute callout references

text - The String text to process

returns The String with the callout references rendered using the backend templates

Public: Substitute inline macros (e.g., links, images, etc)

Replace inline macros, which may span multiple lines, in the provided text

text - The String text to process

returns The String with the inline macros rendered using the backend templates

Public: Substitute post replacements

text - The String text to process

returns The String with the post replacements rendered using the backend templates

Public: Substitute quoted text (includes emphasis, strong, monospaced, etc)

text - The String text to process

returns The String text with quoted text rendered using the backend templates

Public: Substitute replacement characters (e.g., copyright, trademark, etc)

text - The String text to process

returns The String text with the replacement characters substituted

Public: Substitute special characters (i.e., encode XML)

Special characters are defined in the Asciidoctor::SPECIAL_CHARS Array constant

text - The String text to process

returns The String text with special characters replaced

Internal: Transform (render) a quoted text region

match - The MatchData for the quoted text region type - The quoting type (single, double, strong, emphasis, monospaced, etc) scope - The scope of the quoting (constrained or unconstrained)

returns The rendered text for the quoted text region

Internal: Strip bounding whitespace, fold endlines and unescaped closing square brackets from text extracted from brackets

[Validate]