@@ -16,6 +16,7 @@ use crate::optimization::OptimizationMode;
1616use crate :: pipeline:: { Pipeline , StrategyStep } ;
1717use crate :: strategies:: select_strategy;
1818use crate :: template:: { init_tera, validate_templates} ;
19+ use crate :: transforms:: { load_transforms_from_yaml, FailureMode , TransformRegistry } ;
1920
2021/// Run the full build pipeline.
2122///
@@ -120,6 +121,20 @@ fn run_impl(config_path: &str, dry_run: bool, resilient: bool, optimization: Opt
120121 // gracefully. Only write back to disk in non-dry-run mode.
121122 let mut transform_cache = load_cache ( & cache_path) ;
122123
124+ // Load command-based transforms from the YAML file specified in config, if any.
125+ // These are applied after the standard built-in pipeline (emoji, variables, syntax).
126+ let command_registry: Option < TransformRegistry > = if let Some ( ref path) = config. transforms {
127+ info ! ( path = %path, "Loading command-based transforms" ) ;
128+ let mode = if resilient { FailureMode :: ContinueOnError } else { FailureMode :: FailFast } ;
129+ Some (
130+ load_transforms_from_yaml ( path)
131+ . with_context ( || format ! ( "Failed to load command-based transforms from '{}'" , path) ) ?
132+ . with_failure_mode ( mode) ,
133+ )
134+ } else {
135+ None
136+ } ;
137+
123138 pb. set_message ( if dry_run { "[DRY RUN] Applying transforms" } else { "Applying transforms" } ) ;
124139 let mut format_transformed: HashMap < String , String > = HashMap :: new ( ) ;
125140 for output in & config. outputs {
@@ -139,9 +154,18 @@ fn run_impl(config_path: &str, dry_run: bool, resilient: bool, optimization: Opt
139154 } else {
140155 Pipeline :: with_standard_transforms ( & config. variables , format)
141156 } ;
142- pipeline
157+ let standard_output = pipeline
143158 . run_transforms ( normalized_content. as_ref ( ) . to_owned ( ) )
144- . with_context ( || format ! ( "Transform pipeline failed for format: {format_str}; aborting build" ) ) ?
159+ . with_context ( || format ! ( "Transform pipeline failed for format: {format_str}; aborting build" ) ) ?;
160+ // Apply command-based transforms (e.g. ImageMagick, Pandoc) if configured.
161+ if let Some ( ref cmd_registry) = command_registry {
162+ debug ! ( format = %format_str, "Applying command-based transforms" ) ;
163+ cmd_registry
164+ . apply_all ( standard_output)
165+ . with_context ( || format ! ( "Command transform pipeline failed for format: {format_str}" ) ) ?
166+ } else {
167+ standard_output
168+ }
145169 } ;
146170
147171 if !dry_run {
0 commit comments