feat: markdown export
This commit is contained in:
parent
545db900cd
commit
caa7c0aacd
4 changed files with 228 additions and 1 deletions
23
examples/markdown.rs
Normal file
23
examples/markdown.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//! ```bash
|
||||
//! cargo run --example markdown test.org
|
||||
//! ```
|
||||
|
||||
use orgize::{export::MarkdownExport, Org};
|
||||
use std::{env::args, fs};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = args().collect();
|
||||
|
||||
if args.len() < 2 {
|
||||
panic!("Usage: {} <org-mode-file>", args[0]);
|
||||
}
|
||||
|
||||
let content = fs::read_to_string(&args[1]).unwrap();
|
||||
|
||||
let mut export = MarkdownExport::default();
|
||||
Org::parse(&content).traverse(&mut export);
|
||||
|
||||
fs::write(format!("{}.md", &args[1]), export.finish()).unwrap();
|
||||
|
||||
println!("Wrote to {}.md", &args[1]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue