Introducing orgize, an org-mode parser

Orgize is a Rust library for parsing org-mode files:

use orgize::Org;

let org = Org::parse("* DONE Title :tag:");

for event in org.iter() {
    // handling the event
}

orgize also supports export to different formats, like html and json:

// export to html
let mut writer = Vec::new();
org.html(&mut writer).unwrap();
println!("{}", String::from_utf8(writer).unwrap());

// export to json, using serde
use serde_json::to_string;

println!("{}", to_string(&org).unwrap());

Features:

  1. zero-copy: parser is built upon nom, outputs Cow::Borrowed when possible

  2. serde support

  3. custom handler for html/org exporting example1 example2

Similar Projects:

org-rs: another org-mode parser written in Rust, aims to port the elisp parser to Rust. Unlike orgize, org-rs parser is built with regex.

...

Further Work:

  1. implement more parser, such as LaTeX Environments, check out STATUS.md for more detail

  2. more documents

  3. more testings

I've been continuously working on orgize for about nine months and it is still not yet finished. For some personal reasons, I might be inactive for a while. So if you want to share your idea or even contribute, I will really appreciate it. : )

4 Likes

Would be awesome to have also the orgmode LSP, like texlab did for TeX. Also, you might want check the issues and tests from the vim-orgmode plugin that parses orgmode files, for inspiration.

Does it support the code snippets?

Well, I have no ideas for how to implement a LSP server. And it is beyond the scope of this project.

I'm not a expert of VimScript, but it looks like it parses orgmode file using regex which is totally different from orgize.

What do you mean code snippets? Evaluating a code block? In that case, no. orgize serves as a org-mode parser which will not modify the original text. It might be implemented in the future when exporting a org-mode file to another org-mode file, but for now, I will focus on the parser only. : )

I just created a heroku website for demonstrating: https://orgize.herokuapp.com/. If you're interested in this project but bother to use cargo, please take a look. : )