Crates.io | reorg |
lib.rs | reorg |
version | 0.1.0 |
source | src |
created_at | 2019-04-17 23:10:39.644967 |
updated_at | 2019-04-17 23:10:39.644967 |
description | Module to read org-mode files. |
homepage | https://github.com/rodrigovalin/reorg |
repository | https://github.com/rodrigovalin/reorg.git |
max_upload_size | |
id | 128602 |
size | 12,149 |
reorg
is a convenient library to read org-mode files from Rust.
It has many limitations as of now, as it can only read very simple files. A file is a collection of Sections, each section contains a heading: a line with one or more '*' and a title. After the heading section a contents section is expected, which is a multi-line string.
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");