module Asciidoctor::Substitutors

def apply_subs text, subs = NORMAL_SUBS

Returns a String or String Array to match the type of the text argument with substitutions applied.

subs - The substitutions to perform; must be a Symbol Array or nil (default: NORMAL_SUBS).
text - The String or String Array of text to process; must not be nil.

Public: Apply the specified substitutions to the text.
def apply_subs text, subs = NORMAL_SUBS
  return text if text.empty? || !subs
  if (is_multiline = ::Array === text)
    text = text[1] ? (text.join LF) : text[0]
  end
  if subs.include? :macros
    text = extract_passthroughs text
    unless @passthroughs.empty?
      passthrus = @passthroughs
      # NOTE placeholders can move around, so we can only clear in the outermost substitution call
      @passthroughs_locked ||= (clear_passthrus = true)
    end
  end
  subs.each do |type|
    case type
    when :specialcharacters
      text = sub_specialchars text
    when :quotes
      text = sub_quotes text
    when :attributes
      text = sub_attributes text if text.include? ATTR_REF_HEAD
    when :replacements
      text = sub_replacements text
    when :macros
      text = sub_macros text
    when :highlight
      text = highlight_source text, (subs.include? :callouts)
    when :callouts
      text = sub_callouts text unless subs.include? :highlight
    when :post_replacements
      text = sub_post_replacements text
    else
      logger.warn %(unknown substitution type #{type})
    end
  end
  if passthrus
    text = restore_passthroughs text
    if clear_passthrus
      passthrus.clear
      @passthroughs_locked = nil
    end
  end
  is_multiline ? (text.split LF, -1) : text
end