pub fn substitute<'a, 'b>(
text: &'b str,
substitutions: &[Substitution],
attributes: &DocumentAttributes<'a>,
) -> Cow<'b, str>where
'a: 'b,Expand description
Apply a sequence of substitutions to text.
Iterates through the substitution list and applies each in order:
Attributes- Expands{name}references using document attributesNormal/Verbatim- Recursively applies the corresponding substitution group- All others (
SpecialChars,Quotes,Replacements,Macros,PostReplacements,Callouts) - No-op; handled by converters
ยงExample
use acdc_parser::{DocumentAttributes, AttributeValue, Substitution, substitute};
let mut attrs = DocumentAttributes::default();
attrs.set("version".into(), AttributeValue::String("1.0".into()));
let result = substitute("Version {version}", &[Substitution::Attributes], &attrs);
assert_eq!(result, "Version 1.0");