Module | Asciidoctor::Substitutors |
In: |
lib/asciidoctor/substitutors.rb
|
SPECIAL_CHARS | = | { '&' => '&', '<' => '<', '>' => '>' | ||
SPECIAL_CHARS_PATTERN | = | /[#{SPECIAL_CHARS.keys.join}]/ | ||
SUBS | = | { :basic => [:specialcharacters], :normal => [:specialcharacters, :quotes, :attributes, :replacements, :macros, :post_replacements], :verbatim => [:specialcharacters, :callouts], :title => [:specialcharacters, :quotes, :replacements, :macros, :attributes, :post_replacements], :header => [:specialcharacters, :attributes], # by default, AsciiDoc performs :attributes and :macros on a pass block # TODO make this a compliance setting :pass => [] | ||
COMPOSITE_SUBS | = | { :none => [], :normal => SUBS[:normal], :verbatim => SUBS[:verbatim], :specialchars => [:specialcharacters] | ||
SUB_SYMBOLS | = | { :a => :attributes, :m => :macros, :n => :normal, :p => :post_replacements, :q => :quotes, :r => :replacements, :c => :specialcharacters, :v => :verbatim | ||
SUB_OPTIONS | = | { :block => COMPOSITE_SUBS.keys + SUBS[:normal] + [:callouts], :inline => COMPOSITE_SUBS.keys + SUBS[:normal] | ||
SUB_HIGHLIGHT | = | ['coderay', 'pygments'] | ||
PASS_START | = | "\u0096" | SPA, start of guarded protected area (\u0096) | |
PASS_END | = | "\u0097" | EPA, end of guarded protected area (\u0097) | |
PASS_MATCH | = | /\u0096(\d+)\u0097/ | match placeholder record | |
PASS_MATCH_HI | = | /<span[^>]*>\u0096<\/span>[^\d]*(\d+)[^\d]*<span[^>]*>\u0097<\/span>/ | fix placeholder record after syntax highlighting |
Public: Apply the specified substitutions to the lines of text
source - The String or String Array of text to process subs - The substitutions to perform. Can be a Symbol or a Symbol Array (default: :normal) expand - A Boolean to control whether sub aliases are expanded (default: true)
returns Either a String or String Array, whichever matches the type of the first argument
Internal: Convert 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 converted String text for the quoted text region
Internal: Substitute replacement text for matched location
returns The String text with the replacement characters substituted
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
Callout marks are stripped from the source prior to passing it to the highlighter, then later restored in converted form, so they are not incorrectly processed by the source highlighter.
source - the source code String to highlight process_callouts - a Boolean flag indicating whether callout marks should be substituted
returns the highlighted source code, if a source highlighter is defined on the document, otherwise the source with verbatim substituions applied
Internal: Lock-in the substitutions for this block
Looks for an attribute named "subs". If present, resolves the substitutions and assigns it to the subs property on this block. Otherwise, assigns a set of default substitutions based on the content model of the block.
Returns nothing
Internal: Split text formatted as CSV with support for double-quoted values (in which commas are ignored)
Public: Apply verbatim substitutions on source (for use when highlighting is disabled).
source - the source code String on which to apply verbatim substitutions process_callouts - a Boolean flag indicating whether callout marks should be substituted
returns the substituted source
Internal: Strip bounding whitespace, fold endlines and unescaped closing square brackets from text extracted from brackets