-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from dpc/push-turpplvouryy
feat: add `jotdown` for comparison
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |