parse_config_string

Function parse_config_string 

Source
pub fn parse_config_string(config_str: &str) -> StyleMatch
Expand description

Parses a TOML configuration string and returns a complete StyleMatch.

This function handles the core TOML parsing logic and can be used with both embedded configuration strings (via include_str!) and runtime-loaded files. It processes all style sections and returns a complete StyleMatch object containing the full configuration.

By default, code blocks and inline code are rendered with Space Mono embedded font (a fixed-width font ideal for displaying code).

§Arguments

  • config_str - The TOML configuration content as a string

§Returns

A complete StyleMatch with parsed configuration, or default values if parsing fails

§Example

use markdown2pdf::config::parse_config_string;

// Parse configuration with custom code block styling
let config = r#"
[heading.1]
size = 18
bold = true

[code]
fontfamily = "Space Mono"
size = 10
backgroundcolor = { r = 245, g = 245, b = 245 }
"#;
let style = parse_config_string(config);
assert_eq!(style.heading_1.size, 18);
assert_eq!(style.code.font_family, Some("Space Mono"));