pub fn generate_table_of_contents(html: &str) -> Result<String>
Expand description
Generates a table of contents from HTML content.
§Arguments
html
- A string slice that holds the HTML content to process.
§Returns
Result<String>
- The generated table of contents as an HTML string, or an error.
§Examples
use html_generator::utils::generate_table_of_contents;
let html = "<h1>Title</h1><p>Some content</p><h2>Subtitle</h2><p>More content</p>";
let result = generate_table_of_contents(html).unwrap();
assert_eq!(result, r#"<ul><li class="toc-h1"><a href="\#title">Title</a></li><li class="toc-h2"><a href="\#subtitle">Subtitle</a></li></ul>"#);