def apply_subs source, subs = :normal, expand = false
if !subs
return source
elsif subs == :normal
subs = SUBS[:normal]
elsif expand
if ::Symbol === subs
subs = COMPOSITE_SUBS[subs] || [subs]
else
effective_subs = []
subs.each do |key|
if COMPOSITE_SUBS.has_key? key
effective_subs += COMPOSITE_SUBS[key]
else
effective_subs << key
end
end
subs = effective_subs
end
end
return source if subs.empty?
text = (multiline = ::Array === source) ? source * EOL : source
if (has_passthroughs = subs.include? :macros)
text = extract_passthroughs text
has_passthroughs = false if @passthroughs.empty?
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.split EOL) * EOL
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
warn %(asciidoctor: WARNING: unknown substitution type #{type})
end
end
text = restore_passthroughs text if has_passthroughs
multiline ? (text.split EOL) : text
end