diff --git a/STATUS.md b/STATUS.md index fd642d0..b435e14 100644 --- a/STATUS.md +++ b/STATUS.md @@ -21,7 +21,7 @@ - [x] Blocks - [ ] Clock, Diary Sexp and Planning - [x] Comments -- [ ] Fixed Width Areas +- [x] Fixed Width Areas - [x] Horizontal Rules - [x] Keywords - [ ] LaTeX Environments diff --git a/src/elements/mod.rs b/src/elements/mod.rs index 06da443..78926d8 100644 --- a/src/elements/mod.rs +++ b/src/elements/mod.rs @@ -70,6 +70,7 @@ pub enum Element<'a> { }, Rule, Comment(&'a str), + FixedWidth(&'a str), List { ident: usize, ordered: bool, @@ -178,6 +179,14 @@ impl<'a> Element<'a> { } } + if bytes[pos] == b':' && bytes.get(pos + 1).map(|&b| b == b' ').unwrap_or(false) { + let eol = src[pos..] + .find('\n') + .map(|i| i + pos + 1) + .unwrap_or_else(|| src.len()); + ret!(Element::FixedWidth(&src[pos + 1..eol]), eol); + } + if bytes[pos] == b'#' && bytes.get(pos + 1).filter(|&&b| b == b'+').is_some() { if let Some((name, args, contents_beg, cont_end, end)) = Block::parse(&src[pos..]) diff --git a/src/export/html.rs b/src/export/html.rs index 803e1e6..6d24313 100644 --- a/src/export/html.rs +++ b/src/export/html.rs @@ -90,6 +90,9 @@ impl Handler for HtmlHandler { fn handle_comment(&mut self, w: &mut W, cont: &str) -> Result<()> { Ok(()) } + fn handle_fixed_width(&mut self, w: &mut W, cont: &str) -> Result<()> { + write!(w, "
{}
", cont) + } fn handle_table_start(&mut self, w: &mut W) -> Result<()> { Ok(()) } diff --git a/src/export/mod.rs b/src/export/mod.rs index f3c5984..d7699dd 100644 --- a/src/export/mod.rs +++ b/src/export/mod.rs @@ -35,6 +35,7 @@ pub trait Handler { fn handle_call(&mut self, w: &mut W) -> Result<()>; fn handle_clock(&mut self, w: &mut W) -> Result<()>; fn handle_comment(&mut self, w: &mut W, cont: &str) -> Result<()>; + fn handle_fixed_width(&mut self, w: &mut W, cont: &str) -> Result<()>; fn handle_table_start(&mut self, w: &mut W) -> Result<()>; fn handle_table_end(&mut self, w: &mut W) -> Result<()>; fn handle_table_cell(&mut self, w: &mut W) -> Result<()>; @@ -118,6 +119,7 @@ impl<'a, W: Write, H: Handler> Render<'a, W, H> { Call => h.handle_call(w)?, Clock => h.handle_clock(w)?, Comment(c) => h.handle_comment(w, c)?, + FixedWidth(f) => h.handle_fixed_width(w, f)?, TableStart => h.handle_table_start(w)?, TableEnd => h.handle_table_end(w)?, TableCell => h.handle_table_cell(w)?, diff --git a/src/parser.rs b/src/parser.rs index d42235e..9b0f789 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -122,6 +122,7 @@ pub enum Event<'a> { Clock, Comment(&'a str), + FixedWidth(&'a str), TableStart, TableEnd, @@ -259,6 +260,7 @@ impl<'a> Parser<'a> { Element::DynBlock { name, args, .. } => Event::DynBlockBeg { name, args }, Element::ExampleBlock { args, cont } => Event::ExampleBlock { args, cont }, Element::ExportBlock { args, cont } => Event::ExportBlock { args, cont }, + Element::FixedWidth(f) => Event::FixedWidth(f), Element::FnDef { label, cont } => Event::FnDef { label, cont }, Element::Keyword { key, value } => Event::Keyword { key, value }, Element::List { ordered, .. } => Event::ListBeg { ordered },