rust parser ; yaaayy i can now claim this project as fast.

This commit is contained in:
2025-09-23 17:47:30 +02:00
parent c7f0fae19b
commit a149009559
7 changed files with 211 additions and 9 deletions

37
fastmd/src/main.rs Normal file
View File

@@ -0,0 +1,37 @@
use std::{env, fs, process};
use pulldown_cmark::{Parser, Options, html};
fn main() {
// Get the file path from CLI args
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
eprintln!("Usage: {} <markdown_file>", args[0]);
process::exit(1);
}
let path = &args[1];
// Read file contents
let markdown = match fs::read_to_string(path) {
Ok(content) => content,
Err(e) => {
eprintln!("Error reading {}: {}", path, e);
process::exit(1);
}
};
// Configure parser with GitHub-flavored options
let mut options = Options::empty();
options.insert(Options::ENABLE_TABLES);
options.insert(Options::ENABLE_FOOTNOTES);
options.insert(Options::ENABLE_STRIKETHROUGH);
options.insert(Options::ENABLE_TASKLISTS);
// Parse and render to HTML
let parser = Parser::new_ext(&markdown, options);
let mut html_output = String::new();
html::push_html(&mut html_output, parser);
// Print only the body content (no <html>/<head>)
println!("{} <!-- this was generated from rust with pulldown_cmark ; REASON: Large File -->", html_output);
}