diff --git a/org_mode_samples/document/empty.org b/org_mode_samples/document/empty.org new file mode 100644 index 00000000..e69de29b diff --git a/org_mode_samples/document/only_line_breaks.org b/org_mode_samples/document/only_line_breaks.org new file mode 100644 index 00000000..fd40910d --- /dev/null +++ b/org_mode_samples/document/only_line_breaks.org @@ -0,0 +1,4 @@ + + + + diff --git a/org_mode_samples/sections_and_headings/document_post_blank.org b/org_mode_samples/document/post_blank.org similarity index 100% rename from org_mode_samples/sections_and_headings/document_post_blank.org rename to org_mode_samples/document/post_blank.org diff --git a/src/parser/document.rs b/src/parser/document.rs index 65aabc38..8c783ccb 100644 --- a/src/parser/document.rs +++ b/src/parser/document.rs @@ -3,6 +3,7 @@ use std::path::Path; use nom::combinator::all_consuming; use nom::combinator::opt; use nom::multi::many0; +use nom::InputTake; use super::headline::heading; use super::in_buffer_settings::apply_in_buffer_settings; @@ -195,9 +196,9 @@ fn _document<'b, 'g, 'r, 's>( zeroth_section, children, contents: if contents.len() > 0 { - Some(Into::<&str>::into(contents)) + Into::<&str>::into(contents) } else { - None + Into::<&str>::into(remaining.take(0)) }, }, )) diff --git a/src/types/document.rs b/src/types/document.rs index e39e19cb..e9269409 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -17,7 +17,7 @@ pub struct Document<'s> { pub path: Option, pub zeroth_section: Option>, pub children: Vec>, - pub contents: Option<&'s str>, + pub contents: &'s str, } #[derive(Debug)] @@ -64,7 +64,7 @@ impl<'s> StandardProperties<'s> for Document<'s> { } fn get_contents<'b>(&'b self) -> Option<&'s str> { - self.contents + Some(self.contents) } fn get_post_blank(&self) -> PostBlank {