pub fn load_config_from_source(source: ConfigSource<'_>) -> StyleMatchExpand description
Loads and parses the complete styling configuration based on the provided source.
This function handles different configuration sources: default styles, file-based configuration, or embedded TOML strings. It processes all style sections and returns a complete StyleMatch object containing the full configuration.
§Default Code Block Styling
By default, markdown code blocks (or*) and inline code (code) are
rendered using Courier New, a fixed-width font ideal for displaying code.
This can be customized in the TOML configuration file by specifying a different
font family under the [code] section (e.g., “Courier”, “Monaco”, “Consolas”).
§Arguments
source- The configuration source (Default, File, or Embedded)
§Returns
A complete StyleMatch with the appropriate configuration applied
§Examples
use markdown2pdf::config::{ConfigSource, load_config_from_source};
// Use default configuration (code blocks use Courier New)
let style = load_config_from_source(ConfigSource::Default);
assert!(style.code.font_family.is_some());
// Load from file
let style = load_config_from_source(ConfigSource::File("config.toml"));
// Use embedded configuration with custom code block font
const EMBEDDED: &str = r#"
[heading.1]
size = 18
bold = true
[code]
fontfamily = "Courier New"
size = 10
backgroundcolor = { r = 245, g = 245, b = 245 }
"#;
let style = load_config_from_source(ConfigSource::Embedded(EMBEDDED));