Skip to main content

substitute

Function substitute 

Source
pub fn substitute(
    text: &str,
    substitutions: &[Substitution],
    attributes: &DocumentAttributes,
) -> String
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 attributes
  • Normal / 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".to_string(), AttributeValue::String("1.0".to_string()));

let result = substitute("Version {version}", &[Substitution::Attributes], &attrs);
assert_eq!(result, "Version 1.0");