use std::error::Error;
use tform::{Config, Formatter};
fn main() -> Result<(), Box<dyn Error>> {
let config_path = "tform_config.toml";
let config = match Config::from_file(config_path) {
Ok(cfg) => {
println!("Loaded custom config from '{}'", config_path);
cfg
}
Err(e) => {
eprintln!("Could not load config from '{}': {}. Using default config instead.", config_path, e);
Config::default()
}
};
let formatter = Formatter::new(config);
let input_text = r#"
## Custom Rules Example
TODO: This line might be detected by a custom pattern if configured.
+ Additional bullet
+ Another bullet
```rust
fn main() {
println!("Hello from custom rules!");
}
"#;
let markdown_output = formatter.format_to_markdown(input_text.as_bytes())?;
println!("=== Markdown Output (With Custom Rules) ===\n{}", markdown_output);
let html_output = formatter.format_to_html(input_text.as_bytes())?;
println!("=== HTML Output (With Custom Rules) ===\n{}", html_output);
Ok(())
}