diff --git a/src/elements/block.rs b/src/elements/block.rs index 0a94c27..f5f8ed6 100644 --- a/src/elements/block.rs +++ b/src/elements/block.rs @@ -9,13 +9,12 @@ pub fn parse(text: &str) -> Option<(&str, Option<&str>, usize, usize, usize)> { return None; } - let bytes = text.as_bytes(); let mut lines = memchr_iter(b'\n', text.as_bytes()); let (name, para, off) = lines .next() .map(|i| { - memchr(b' ', &bytes[8..i]) + memchr(b' ', &text.as_bytes()[8..i]) .map(|x| (&text[8..8 + x], Some(text[8 + x..i].trim()), i + 1)) .unwrap_or((&text[8..i], None, i + 1)) }) diff --git a/src/export/html.rs b/src/export/html.rs index 745a6cb..54a6c5f 100644 --- a/src/export/html.rs +++ b/src/export/html.rs @@ -1,11 +1,6 @@ #![allow(unused_variables)] -use crate::{ - elements::{Key, Planning}, - headline::Headline, - objects::{Cookie, Timestamp}, - parser::Parser, -}; +use crate::{elements::*, headline::Headline, objects::*, Parser}; use jetscii::bytes; use std::{ convert::From, @@ -130,7 +125,7 @@ pub trait HtmlHandler> { fn call(&mut self, w: &mut W, value: &str) -> Result<(), E> { Ok(()) } - fn clock(&mut self, w: &mut W) -> Result<(), E> { + fn clock(&mut self, w: &mut W, clock: Clock<'_>) -> Result<(), E> { Ok(()) } fn comment(&mut self, w: &mut W, cont: &str) -> Result<(), E> { diff --git a/src/export/mod.rs b/src/export/mod.rs index e5992eb..4bd9809 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -31,7 +31,7 @@ macro_rules! handle_event { ListItemEnd => $handler.list_end_item($writer)?, Call { value } => $handler.call($writer, value)?, Planning(p) => $handler.planning($writer, p)?, - Clock => $handler.clock($writer)?, + Clock(c) => $handler.clock($writer, c)?, Timestamp(t) => $handler.timestamp($writer, t)?, Comment(c) => $handler.comment($writer, c)?, FixedWidth(f) => $handler.fixed_width($writer, f)?, diff --git a/src/parser.rs b/src/parser.rs index 6059024..d4172ef 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -86,7 +86,7 @@ pub enum Event<'a> { value: &'a str, }, - Clock, + Clock(Clock<'a>), Comment(&'a str), FixedWidth(&'a str), @@ -335,6 +335,12 @@ impl<'a> Parser<'a> { return Some((Event::ListBeg { ordered }, 0, line_begin, text.len())); } + if tail.starts_with("CLOCK:") { + if let Some((clock, off)) = Clock::parse(tail) { + return Some((Event::Clock(clock), off + line_begin, 0, 0)); + } + } + // TODO: LaTeX environment if tail.starts_with("\\begin{") {}