Skip to content

Commit

Permalink
feat: add jotdown for comparison
Browse files Browse the repository at this point in the history
Djot is a "kind-of-more-strict-Markdown" that is (supposedly) make
it faster and easier to parse. I am curious myself how well it
performs.
  • Loading branch information
dpc committed Feb 4, 2025
1 parent 68445eb commit 358e17e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions examples/jotdown-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "jotdown-app"
edition.workspace = true

[[bin]]
name = "jotdown-app"
path = "app.rs"

[dependencies]
jotdown = "0.7.0"
32 changes: 32 additions & 0 deletions examples/jotdown-app/app.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::io::Write;

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let mut args = std::env::args_os();
let _bin = args.next();
let path = args.next().expect("no markdown path given");
let raw = std::fs::read_to_string(path)?;
#[cfg(debug_assertions)]
{
let stdout = std::io::stdout();
let mut stdout = stdout.lock();
render(&mut stdout, &raw)?;
}
#[cfg(not(debug_assertions))]
{
let mut buffer = Vec::new();
render(&mut buffer, &raw)?;
std::hint::black_box(buffer);
}
Ok(())
}

fn render(
writer: &mut dyn Write,
raw: &str,
) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let events = jotdown::Parser::new(raw);
let html = jotdown::html::render_to_string(events);
let _ = writeln!(writer, "{:?}", html);

Ok(())
}

0 comments on commit 358e17e

Please sign in to comment.