diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 3b7a382..6475a05 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -1575,7 +1575,7 @@ fn compare_example_block<'b, 's>( [], ( EmacsField::Required(":value"), - |r| Some(r.get_contents()), + |r| Some(r.get_value()), compare_property_quoted_string ), ( @@ -1653,7 +1653,7 @@ fn compare_export_block<'b, 's>( ), ( EmacsField::Required(":value"), - |r| Some(r.get_contents()), + |r| Some(r.get_value()), compare_property_quoted_string ) ) { @@ -1701,7 +1701,7 @@ fn compare_src_block<'b, 's>( ), ( EmacsField::Required(":value"), - |r| Some(r.get_contents()), + |r| Some(r.get_value()), compare_property_quoted_string ), ( diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index 1241cf2..a09ce0d 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -236,7 +236,7 @@ where retain_labels, use_labels, label_format, - contents: Into::<&str>::into(contents), + value: Into::<&str>::into(contents), }, )) } @@ -292,7 +292,7 @@ where ), export_type: export_type.map(Into::<&str>::into), data: parameters.map(Into::<&str>::into), - contents: Into::<&str>::into(contents), + value: Into::<&str>::into(contents), }, )) } @@ -371,7 +371,7 @@ where retain_labels, use_labels, label_format, - contents: Into::<&str>::into(contents), + value: Into::<&str>::into(contents), }, )) } diff --git a/src/types/ast_node.rs b/src/types/ast_node.rs index 026931a..75749d3 100644 --- a/src/types/ast_node.rs +++ b/src/types/ast_node.rs @@ -322,4 +322,130 @@ impl<'r, 's> StandardProperties<'s> for AstNode<'r, 's> { AstNode::Timestamp(inner) => inner.get_source(), } } + + fn get_contents(&'s self) -> &'s str { + match self { + AstNode::Document(inner) => inner.get_contents(), + AstNode::Heading(inner) => inner.get_contents(), + AstNode::Section(inner) => inner.get_contents(), + AstNode::Paragraph(inner) => inner.get_contents(), + AstNode::PlainList(inner) => inner.get_contents(), + AstNode::PlainListItem(inner) => inner.get_contents(), + AstNode::CenterBlock(inner) => inner.get_contents(), + AstNode::QuoteBlock(inner) => inner.get_contents(), + AstNode::SpecialBlock(inner) => inner.get_contents(), + AstNode::DynamicBlock(inner) => inner.get_contents(), + AstNode::FootnoteDefinition(inner) => inner.get_contents(), + AstNode::Comment(inner) => inner.get_contents(), + AstNode::Drawer(inner) => inner.get_contents(), + AstNode::PropertyDrawer(inner) => inner.get_contents(), + AstNode::NodeProperty(inner) => inner.get_contents(), + AstNode::Table(inner) => inner.get_contents(), + AstNode::TableRow(inner) => inner.get_contents(), + AstNode::VerseBlock(inner) => inner.get_contents(), + AstNode::CommentBlock(inner) => inner.get_contents(), + AstNode::ExampleBlock(inner) => inner.get_contents(), + AstNode::ExportBlock(inner) => inner.get_contents(), + AstNode::SrcBlock(inner) => inner.get_contents(), + AstNode::Clock(inner) => inner.get_contents(), + AstNode::DiarySexp(inner) => inner.get_contents(), + AstNode::Planning(inner) => inner.get_contents(), + AstNode::FixedWidthArea(inner) => inner.get_contents(), + AstNode::HorizontalRule(inner) => inner.get_contents(), + AstNode::Keyword(inner) => inner.get_contents(), + AstNode::BabelCall(inner) => inner.get_contents(), + AstNode::LatexEnvironment(inner) => inner.get_contents(), + AstNode::Bold(inner) => inner.get_contents(), + AstNode::Italic(inner) => inner.get_contents(), + AstNode::Underline(inner) => inner.get_contents(), + AstNode::StrikeThrough(inner) => inner.get_contents(), + AstNode::Code(inner) => inner.get_contents(), + AstNode::Verbatim(inner) => inner.get_contents(), + AstNode::PlainText(inner) => inner.get_contents(), + AstNode::RegularLink(inner) => inner.get_contents(), + AstNode::RadioLink(inner) => inner.get_contents(), + AstNode::RadioTarget(inner) => inner.get_contents(), + AstNode::PlainLink(inner) => inner.get_contents(), + AstNode::AngleLink(inner) => inner.get_contents(), + AstNode::OrgMacro(inner) => inner.get_contents(), + AstNode::Entity(inner) => inner.get_contents(), + AstNode::LatexFragment(inner) => inner.get_contents(), + AstNode::ExportSnippet(inner) => inner.get_contents(), + AstNode::FootnoteReference(inner) => inner.get_contents(), + AstNode::Citation(inner) => inner.get_contents(), + AstNode::CitationReference(inner) => inner.get_contents(), + AstNode::InlineBabelCall(inner) => inner.get_contents(), + AstNode::InlineSourceBlock(inner) => inner.get_contents(), + AstNode::LineBreak(inner) => inner.get_contents(), + AstNode::Target(inner) => inner.get_contents(), + AstNode::StatisticsCookie(inner) => inner.get_contents(), + AstNode::Subscript(inner) => inner.get_contents(), + AstNode::Superscript(inner) => inner.get_contents(), + AstNode::TableCell(inner) => inner.get_contents(), + AstNode::Timestamp(inner) => inner.get_contents(), + } + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + match self { + AstNode::Document(inner) => inner.get_post_blank(), + AstNode::Heading(inner) => inner.get_post_blank(), + AstNode::Section(inner) => inner.get_post_blank(), + AstNode::Paragraph(inner) => inner.get_post_blank(), + AstNode::PlainList(inner) => inner.get_post_blank(), + AstNode::PlainListItem(inner) => inner.get_post_blank(), + AstNode::CenterBlock(inner) => inner.get_post_blank(), + AstNode::QuoteBlock(inner) => inner.get_post_blank(), + AstNode::SpecialBlock(inner) => inner.get_post_blank(), + AstNode::DynamicBlock(inner) => inner.get_post_blank(), + AstNode::FootnoteDefinition(inner) => inner.get_post_blank(), + AstNode::Comment(inner) => inner.get_post_blank(), + AstNode::Drawer(inner) => inner.get_post_blank(), + AstNode::PropertyDrawer(inner) => inner.get_post_blank(), + AstNode::NodeProperty(inner) => inner.get_post_blank(), + AstNode::Table(inner) => inner.get_post_blank(), + AstNode::TableRow(inner) => inner.get_post_blank(), + AstNode::VerseBlock(inner) => inner.get_post_blank(), + AstNode::CommentBlock(inner) => inner.get_post_blank(), + AstNode::ExampleBlock(inner) => inner.get_post_blank(), + AstNode::ExportBlock(inner) => inner.get_post_blank(), + AstNode::SrcBlock(inner) => inner.get_post_blank(), + AstNode::Clock(inner) => inner.get_post_blank(), + AstNode::DiarySexp(inner) => inner.get_post_blank(), + AstNode::Planning(inner) => inner.get_post_blank(), + AstNode::FixedWidthArea(inner) => inner.get_post_blank(), + AstNode::HorizontalRule(inner) => inner.get_post_blank(), + AstNode::Keyword(inner) => inner.get_post_blank(), + AstNode::BabelCall(inner) => inner.get_post_blank(), + AstNode::LatexEnvironment(inner) => inner.get_post_blank(), + AstNode::Bold(inner) => inner.get_post_blank(), + AstNode::Italic(inner) => inner.get_post_blank(), + AstNode::Underline(inner) => inner.get_post_blank(), + AstNode::StrikeThrough(inner) => inner.get_post_blank(), + AstNode::Code(inner) => inner.get_post_blank(), + AstNode::Verbatim(inner) => inner.get_post_blank(), + AstNode::PlainText(inner) => inner.get_post_blank(), + AstNode::RegularLink(inner) => inner.get_post_blank(), + AstNode::RadioLink(inner) => inner.get_post_blank(), + AstNode::RadioTarget(inner) => inner.get_post_blank(), + AstNode::PlainLink(inner) => inner.get_post_blank(), + AstNode::AngleLink(inner) => inner.get_post_blank(), + AstNode::OrgMacro(inner) => inner.get_post_blank(), + AstNode::Entity(inner) => inner.get_post_blank(), + AstNode::LatexFragment(inner) => inner.get_post_blank(), + AstNode::ExportSnippet(inner) => inner.get_post_blank(), + AstNode::FootnoteReference(inner) => inner.get_post_blank(), + AstNode::Citation(inner) => inner.get_post_blank(), + AstNode::CitationReference(inner) => inner.get_post_blank(), + AstNode::InlineBabelCall(inner) => inner.get_post_blank(), + AstNode::InlineSourceBlock(inner) => inner.get_post_blank(), + AstNode::LineBreak(inner) => inner.get_post_blank(), + AstNode::Target(inner) => inner.get_post_blank(), + AstNode::StatisticsCookie(inner) => inner.get_post_blank(), + AstNode::Subscript(inner) => inner.get_post_blank(), + AstNode::Superscript(inner) => inner.get_post_blank(), + AstNode::TableCell(inner) => inner.get_post_blank(), + AstNode::Timestamp(inner) => inner.get_post_blank(), + } + } } diff --git a/src/types/document.rs b/src/types/document.rs index 8328b72..ccb468a 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -57,18 +57,42 @@ impl<'s> StandardProperties<'s> for Document<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Section<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Heading<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> Heading<'s> { @@ -126,4 +150,18 @@ impl<'s> StandardProperties<'s> for DocumentElement<'s> { DocumentElement::Section(inner) => inner.get_source(), } } + + fn get_contents(&'s self) -> &'s str { + match self { + DocumentElement::Heading(inner) => inner.get_contents(), + DocumentElement::Section(inner) => inner.get_contents(), + } + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + match self { + DocumentElement::Heading(inner) => inner.get_post_blank(), + DocumentElement::Section(inner) => inner.get_post_blank(), + } + } } diff --git a/src/types/element.rs b/src/types/element.rs index c079f6b..49e54d1 100644 --- a/src/types/element.rs +++ b/src/types/element.rs @@ -82,4 +82,62 @@ impl<'s> StandardProperties<'s> for Element<'s> { Element::LatexEnvironment(inner) => inner.get_source(), } } + + fn get_contents(&'s self) -> &'s str { + match self { + Element::Paragraph(inner) => inner.get_contents(), + Element::PlainList(inner) => inner.get_contents(), + Element::CenterBlock(inner) => inner.get_contents(), + Element::QuoteBlock(inner) => inner.get_contents(), + Element::SpecialBlock(inner) => inner.get_contents(), + Element::DynamicBlock(inner) => inner.get_contents(), + Element::FootnoteDefinition(inner) => inner.get_contents(), + Element::Comment(inner) => inner.get_contents(), + Element::Drawer(inner) => inner.get_contents(), + Element::PropertyDrawer(inner) => inner.get_contents(), + Element::Table(inner) => inner.get_contents(), + Element::VerseBlock(inner) => inner.get_contents(), + Element::CommentBlock(inner) => inner.get_contents(), + Element::ExampleBlock(inner) => inner.get_contents(), + Element::ExportBlock(inner) => inner.get_contents(), + Element::SrcBlock(inner) => inner.get_contents(), + Element::Clock(inner) => inner.get_contents(), + Element::DiarySexp(inner) => inner.get_contents(), + Element::Planning(inner) => inner.get_contents(), + Element::FixedWidthArea(inner) => inner.get_contents(), + Element::HorizontalRule(inner) => inner.get_contents(), + Element::Keyword(inner) => inner.get_contents(), + Element::BabelCall(inner) => inner.get_contents(), + Element::LatexEnvironment(inner) => inner.get_contents(), + } + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + match self { + Element::Paragraph(inner) => inner.get_post_blank(), + Element::PlainList(inner) => inner.get_post_blank(), + Element::CenterBlock(inner) => inner.get_post_blank(), + Element::QuoteBlock(inner) => inner.get_post_blank(), + Element::SpecialBlock(inner) => inner.get_post_blank(), + Element::DynamicBlock(inner) => inner.get_post_blank(), + Element::FootnoteDefinition(inner) => inner.get_post_blank(), + Element::Comment(inner) => inner.get_post_blank(), + Element::Drawer(inner) => inner.get_post_blank(), + Element::PropertyDrawer(inner) => inner.get_post_blank(), + Element::Table(inner) => inner.get_post_blank(), + Element::VerseBlock(inner) => inner.get_post_blank(), + Element::CommentBlock(inner) => inner.get_post_blank(), + Element::ExampleBlock(inner) => inner.get_post_blank(), + Element::ExportBlock(inner) => inner.get_post_blank(), + Element::SrcBlock(inner) => inner.get_post_blank(), + Element::Clock(inner) => inner.get_post_blank(), + Element::DiarySexp(inner) => inner.get_post_blank(), + Element::Planning(inner) => inner.get_post_blank(), + Element::FixedWidthArea(inner) => inner.get_post_blank(), + Element::HorizontalRule(inner) => inner.get_post_blank(), + Element::Keyword(inner) => inner.get_post_blank(), + Element::BabelCall(inner) => inner.get_post_blank(), + Element::LatexEnvironment(inner) => inner.get_post_blank(), + } + } } diff --git a/src/types/greater_element.rs b/src/types/greater_element.rs index e058b42..f459537 100644 --- a/src/types/greater_element.rs +++ b/src/types/greater_element.rs @@ -131,72 +131,168 @@ impl<'s> StandardProperties<'s> for PlainList<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for PlainListItem<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for CenterBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for QuoteBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for SpecialBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for DynamicBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for FootnoteDefinition<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Drawer<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for PropertyDrawer<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for NodeProperty<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Table<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for TableRow<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> PlainListItem<'s> { diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index 41097e4..3241a98 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -75,7 +75,7 @@ pub struct ExampleBlock<'s> { pub retain_labels: RetainLabels, pub use_labels: bool, pub label_format: Option<&'s str>, - pub contents: &'s str, + pub value: &'s str, } #[derive(Debug)] @@ -84,7 +84,7 @@ pub struct ExportBlock<'s> { pub affiliated_keywords: AffiliatedKeywords<'s>, pub export_type: Option<&'s str>, pub data: Option<&'s str>, - pub contents: &'s str, + pub value: &'s str, } #[derive(Debug)] @@ -99,7 +99,7 @@ pub struct SrcBlock<'s> { pub retain_labels: RetainLabels, pub use_labels: bool, pub label_format: Option<&'s str>, - pub contents: &'s str, + pub value: &'s str, } #[derive(Debug)] @@ -198,92 +198,220 @@ impl<'s> StandardProperties<'s> for Paragraph<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for TableCell<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Comment<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for VerseBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for CommentBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for ExampleBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for ExportBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for SrcBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Clock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for DiarySexp<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Planning<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for FixedWidthArea<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for HorizontalRule<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Keyword<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for BabelCall<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for LatexEnvironment<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> Comment<'s> { @@ -312,8 +440,8 @@ impl<'s> FixedWidthArea<'s> { impl<'s> ExampleBlock<'s> { /// Gets the contents of the lesser block, handling the escaping of lines with leading commas. - pub fn get_contents(&self) -> Cow<'s, str> { - lesser_block_content(self.contents).expect("This parser should never fail.") + pub fn get_value(&self) -> Cow<'s, str> { + lesser_block_content(self.value).expect("This parser should never fail.") } } @@ -326,15 +454,15 @@ impl<'s> ExportBlock<'s> { } /// Gets the contents of the lesser block, handling the escaping of lines with leading commas. - pub fn get_contents(&self) -> Cow<'s, str> { - lesser_block_content(self.contents).expect("This parser should never fail.") + pub fn get_value(&self) -> Cow<'s, str> { + lesser_block_content(self.value).expect("This parser should never fail.") } } impl<'s> SrcBlock<'s> { /// Gets the contents of the lesser block, handling the escaping of lines with leading commas. - pub fn get_contents(&self) -> Cow<'s, str> { - lesser_block_content(self.contents).expect("This parser should never fail.") + pub fn get_value(&self) -> Cow<'s, str> { + lesser_block_content(self.value).expect("This parser should never fail.") } } diff --git a/src/types/object.rs b/src/types/object.rs index 9f38eb6..87a23b6 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -518,162 +518,378 @@ impl<'s> StandardProperties<'s> for Bold<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Italic<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Underline<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for StrikeThrough<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Code<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Verbatim<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for RegularLink<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for RadioLink<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for RadioTarget<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for PlainLink<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for AngleLink<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for OrgMacro<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Entity<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for LatexFragment<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for ExportSnippet<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for FootnoteReference<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Citation<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for CitationReference<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for InlineBabelCall<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for InlineSourceBlock<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for LineBreak<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Target<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for StatisticsCookie<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Subscript<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Superscript<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for Timestamp<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> StandardProperties<'s> for PlainText<'s> { fn get_source<'b>(&'b self) -> &'s str { self.source } + + fn get_contents(&'s self) -> &'s str { + todo!() + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + todo!() + } } impl<'s> Timestamp<'s> { @@ -799,4 +1015,68 @@ impl<'s> StandardProperties<'s> for Object<'s> { Object::Timestamp(inner) => inner.get_source(), } } + + fn get_contents(&'s self) -> &'s str { + match self { + Object::Bold(inner) => inner.get_contents(), + Object::Italic(inner) => inner.get_contents(), + Object::Underline(inner) => inner.get_contents(), + Object::StrikeThrough(inner) => inner.get_contents(), + Object::Code(inner) => inner.get_contents(), + Object::Verbatim(inner) => inner.get_contents(), + Object::PlainText(inner) => inner.get_contents(), + Object::RegularLink(inner) => inner.get_contents(), + Object::RadioLink(inner) => inner.get_contents(), + Object::RadioTarget(inner) => inner.get_contents(), + Object::PlainLink(inner) => inner.get_contents(), + Object::AngleLink(inner) => inner.get_contents(), + Object::OrgMacro(inner) => inner.get_contents(), + Object::Entity(inner) => inner.get_contents(), + Object::LatexFragment(inner) => inner.get_contents(), + Object::ExportSnippet(inner) => inner.get_contents(), + Object::FootnoteReference(inner) => inner.get_contents(), + Object::Citation(inner) => inner.get_contents(), + Object::CitationReference(inner) => inner.get_contents(), + Object::InlineBabelCall(inner) => inner.get_contents(), + Object::InlineSourceBlock(inner) => inner.get_contents(), + Object::LineBreak(inner) => inner.get_contents(), + Object::Target(inner) => inner.get_contents(), + Object::StatisticsCookie(inner) => inner.get_contents(), + Object::Subscript(inner) => inner.get_contents(), + Object::Superscript(inner) => inner.get_contents(), + Object::Timestamp(inner) => inner.get_contents(), + } + } + + fn get_post_blank<'b>(&'b self) -> &'s str { + match self { + Object::Bold(inner) => inner.get_post_blank(), + Object::Italic(inner) => inner.get_post_blank(), + Object::Underline(inner) => inner.get_post_blank(), + Object::StrikeThrough(inner) => inner.get_post_blank(), + Object::Code(inner) => inner.get_post_blank(), + Object::Verbatim(inner) => inner.get_post_blank(), + Object::PlainText(inner) => inner.get_post_blank(), + Object::RegularLink(inner) => inner.get_post_blank(), + Object::RadioLink(inner) => inner.get_post_blank(), + Object::RadioTarget(inner) => inner.get_post_blank(), + Object::PlainLink(inner) => inner.get_post_blank(), + Object::AngleLink(inner) => inner.get_post_blank(), + Object::OrgMacro(inner) => inner.get_post_blank(), + Object::Entity(inner) => inner.get_post_blank(), + Object::LatexFragment(inner) => inner.get_post_blank(), + Object::ExportSnippet(inner) => inner.get_post_blank(), + Object::FootnoteReference(inner) => inner.get_post_blank(), + Object::Citation(inner) => inner.get_post_blank(), + Object::CitationReference(inner) => inner.get_post_blank(), + Object::InlineBabelCall(inner) => inner.get_post_blank(), + Object::InlineSourceBlock(inner) => inner.get_post_blank(), + Object::LineBreak(inner) => inner.get_post_blank(), + Object::Target(inner) => inner.get_post_blank(), + Object::StatisticsCookie(inner) => inner.get_post_blank(), + Object::Subscript(inner) => inner.get_post_blank(), + Object::Superscript(inner) => inner.get_post_blank(), + Object::Timestamp(inner) => inner.get_post_blank(), + } + } } diff --git a/src/types/standard_properties.rs b/src/types/standard_properties.rs index 4cd195a..e2ecc62 100644 --- a/src/types/standard_properties.rs +++ b/src/types/standard_properties.rs @@ -5,15 +5,15 @@ pub trait StandardProperties<'s> { /// This corresponds to :begin to :end in upstream org-mode's standard properties. fn get_source<'b>(&'b self) -> &'s str; - // Get the slice of the AST node's contents. - // - // This corresponds to :contents-begin to :contents-end - // fn get_contents(&'s self) -> &'s str; + /// Get the slice of the AST node's contents. + /// + /// This corresponds to :contents-begin to :contents-end + fn get_contents(&'s self) -> &'s str; - // Get the slice of the AST node's post-blank text. - // - // This is optional whitespace following the node. - // fn get_post_blank<'b>(&'b self) -> &'s str; + /// Get the slice of the AST node's post-blank text. + /// + /// This is optional whitespace following the node. + fn get_post_blank<'b>(&'b self) -> &'s str; } // TODO: Write some debugging code to alert when any of the unknown fields below are non-nil in our test data so we can see what these fields represent.