feat(parser): timestamp parsing

This commit is contained in:
PoiScript 2019-04-04 21:08:23 +08:00
parent 1f52e75d3d
commit 1bb5286dd3
12 changed files with 887 additions and 1023 deletions

View file

@ -1,5 +1,5 @@
use crate::elements::{fn_def, keyword, Key};
use crate::headline::Headline;
use crate::headline::{Headline, DEFAULT_KEYWORDS};
use memchr::memchr;
type Headlines<'a> = Vec<Headline<'a>>;
@ -15,7 +15,7 @@ pub fn metadata(src: &str) -> (Headlines<'_>, Keywords<'_>, Footnotes<'_>) {
if line.starts_with('*') {
let level = memchr(b' ', line.as_bytes()).unwrap_or_else(|| line.len());
if line.as_bytes()[0..level].iter().all(|&c| c == b'*') {
headlines.push(Headline::parse(line).0)
headlines.push(Headline::parse(line, DEFAULT_KEYWORDS).0)
}
} else if line.starts_with("#+") {
if let Some((key, value, _)) = keyword::parse(line) {