pub fn format_header_with_id_class(
header: &str,
id_generator: Option<fn(_: &str) -> String>,
class_generator: Option<fn(_: &str) -> String>,
) -> Result<String>
Expand description
Formats a header with an ID and class.
§Arguments
header
- A string slice that holds the HTML header to process.id_generator
- An optional function that generates the ID from the header content.class_generator
- An optional function that generates the class from the header content.
§Returns
Result<String>
- The formatted HTML header, or an error.
§Examples
use html_generator::utils::format_header_with_id_class;
let header = "<h2>Hello, World!</h2>";
let result = format_header_with_id_class(header, None, None).unwrap();
assert_eq!(result, "<h2 id=\"hello-world\" class=\"hello-world\">Hello, World!</h2>");