Function mktoc::generate_toc

source ·
pub fn generate_toc(original_content: String, config: Config) -> String
Expand description

parses a string and extracts all headlines to build a table of contents

Uses a basic regex ((#{1,6}\s))((.*)) to parse headings out of the

use mktoc::*;
let new_toc = generate_toc(String::from("# Hello\n## World"), Config::default());
assert_eq!(new_toc, "<!-- BEGIN mktoc -->\n\n- [Hello](#hello)\n- [World](#world)\n<!-- END mktoc -->");