1 个不稳定版本

0.1.0 2019年4月17日

#17#org-mode

MIT/Apache

12KB
209

reorg

reorg 是一个方便的 Rust 库,用于从 org-mode 文件中读取。

目前它有很多限制,因为它只能读取非常简单的文件。一个文件是一系列节,每个节包含一个标题:一行包含一个或多个 '*' 和一个标题。标题节之后应该是一个内容节,它是一个多行字符串。

示例

let org_doc = String::from("* This is first item
with some content
and a second line
** And we have another title
also with some content");
let doc = reorg::Document::from(org_doc).unwrap();

assert_eq!(doc.sections.borrow()[0].heading.stars, 1);
assert_eq!(doc.sections.borrow()[0].heading.title, "This is first item");
assert_eq!(doc.sections.borrow()[0].children.borrow()[0].heading.stars, 2);
assert_eq!(doc.sections.borrow()[0].children.borrow()[0].heading.title, "And we have another title");

assert_eq!(doc.sections.borrow()[0].content, "with some content\nand a second line\n");
assert_eq!(doc.sections.borrow()[0].children.borrow()[0].content, "also with some content");

依赖项

~2–3MB
~53K SLoC