Module | Asciidoctor::Substitutors |
In: |
lib/asciidoctor/substitutors.rb
|
SpecialCharsRx | = | /[<&>]/ | ||
SpecialCharsTr | = | { '>' => '>', '<' => '<', '&' => '&' } | ||
QuotedTextSniffRx | = | { false => /[*_`#^~]/, true => /[*'_+#^~]/ } | Detects if text is a possible candidate for the quotes substitution. | |
BASIC_SUBS | = | [:specialcharacters]).freeze | ||
HEADER_SUBS | = | [:specialcharacters, :attributes]).freeze | ||
NORMAL_SUBS | = | [:specialcharacters, :quotes, :attributes, :replacements, :macros, :post_replacements]).freeze | ||
NONE_SUBS | = | []).freeze | ||
TITLE_SUBS | = | [:specialcharacters, :quotes, :replacements, :macros, :attributes, :post_replacements]).freeze | ||
REFTEXT_SUBS | = | [:specialcharacters, :quotes, :replacements]).freeze | ||
VERBATIM_SUBS | = | [:specialcharacters, :callouts]).freeze | ||
SUB_GROUPS | = | { :none => NONE_SUBS, :normal => NORMAL_SUBS, :verbatim => VERBATIM_SUBS, :specialchars => BASIC_SUBS | ||
SUB_HINTS | = | { :a => :attributes, :m => :macros, :n => :normal, :p => :post_replacements, :q => :quotes, :r => :replacements, :c => :specialcharacters, :v => :verbatim | ||
SUB_OPTIONS | = | { :block => SUB_GROUPS.keys + NORMAL_SUBS + [:callouts], :inline => SUB_GROUPS.keys + NORMAL_SUBS | ||
SUB_HIGHLIGHT | = | ['coderay', 'pygments'] | ||
PASS_START | = | %(\u0096) | SPA, start of guarded protected area (\u0096) | |
PASS_END | = | %(\u0097) | EPA, end of guarded protected area (\u0097) | |
PassSlotRx | = | /#{PASS_START}(\d+)#{PASS_END}/ | match passthrough slot | |
HighlightedPassSlotRx | = | %r(<span\b[^>]*>#{PASS_START}</span>[^\d]*(\d+)[^\d]*<span\b[^>]*>#{PASS_END}</span>) | fix passthrough slot after syntax highlighting | |
RS | = | '\\' | ||
R_SB | = | ']' | ||
ESC_R_SB | = | '\]' | ||
PLUS | = | '+' | ||
PygmentsWrapperDivRx | = | %r(<div class="pyhl">(.*)</div>)m | ||
PygmentsWrapperPreRx | = | %r(<pre\b[^>]*?>(.*?)</pre>\s*)m | NOTE handles all permutations of <pre> wrapper NOTE trailing whitespace appears when pygments-linenums-mode=table; <pre> has style attribute when pygments-css=inline |
Public: Apply normal substitutions.
An alias for apply_subs with default remaining arguments.
text - The String text to which to apply normal substitutions
Returns the String with normal substitutions applied.
Public: Apply the specified substitutions to the source.
source - The String or String Array of text to process; must not be nil. subs - The substitutions to perform; can be a Symbol, Symbol Array or nil (default: NORMAL_SUBS). expand - A Boolean (or nil) to control whether substitution aliases are expanded (default: nil).
Returns a String or String Array with substitutions applied, matching the type of source 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 substitutions from the value of that attribute and assigns them to the subs property on this block. Otherwise, uses the substitutions assigned to the default_subs property, if specified, or selects a default set of substitutions based on the content model of the block.
Returns The Array of resolved substitutions now assigned to this block
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