Add a GetStandardProperties trait.
This commit is contained in:
parent
d4f27ef297
commit
b4c985071c
@ -29,6 +29,7 @@ use crate::types::ExportSnippet;
|
||||
use crate::types::FixedWidthArea;
|
||||
use crate::types::FootnoteDefinition;
|
||||
use crate::types::FootnoteReference;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::GreaterBlock;
|
||||
use crate::types::Heading;
|
||||
use crate::types::HorizontalRule;
|
||||
@ -54,8 +55,8 @@ use crate::types::RadioLink;
|
||||
use crate::types::RadioTarget;
|
||||
use crate::types::RegularLink;
|
||||
use crate::types::Section;
|
||||
use crate::types::Source;
|
||||
use crate::types::SrcBlock;
|
||||
use crate::types::StandardProperties;
|
||||
use crate::types::StatisticsCookie;
|
||||
use crate::types::StrikeThrough;
|
||||
use crate::types::Subscript;
|
||||
@ -321,7 +322,7 @@ fn compare_element<'s>(
|
||||
name: "error!".to_owned(),
|
||||
message: Some(e.to_string()),
|
||||
children: Vec::new(),
|
||||
rust_source: rust.get_source(),
|
||||
rust_source: rust.get_standard_properties().get_source(),
|
||||
emacs_token: emacs,
|
||||
}
|
||||
.into()),
|
||||
@ -369,7 +370,7 @@ fn compare_object<'s>(
|
||||
name: "error!".to_owned(),
|
||||
message: Some(e.to_string()),
|
||||
children: Vec::new(),
|
||||
rust_source: rust.get_source(),
|
||||
rust_source: rust.get_standard_properties().get_source(),
|
||||
emacs_token: emacs,
|
||||
}
|
||||
.into()),
|
||||
|
@ -187,7 +187,7 @@ mod tests {
|
||||
use crate::context::List;
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::types::Element;
|
||||
use crate::types::Source;
|
||||
use crate::types::GetStandardProperties;
|
||||
|
||||
#[test]
|
||||
fn citation_simple() {
|
||||
@ -202,7 +202,10 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(first_paragraph.get_source(), "[cite:@foo]");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"[cite:@foo]"
|
||||
);
|
||||
assert_eq!(first_paragraph.children.len(), 1);
|
||||
assert_eq!(
|
||||
first_paragraph
|
||||
|
@ -129,7 +129,7 @@ mod tests {
|
||||
use crate::context::Context;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::types::Source;
|
||||
use crate::types::GetStandardProperties;
|
||||
|
||||
#[test]
|
||||
fn two_paragraphs() {
|
||||
@ -150,13 +150,17 @@ line footnote.",
|
||||
footnote_definition_matcher(remaining).expect("Parse second footnote_definition.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_footnote_definition.get_source(),
|
||||
first_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
"[fn:1] A footnote.
|
||||
|
||||
"
|
||||
);
|
||||
assert_eq!(
|
||||
second_footnote_definition.get_source(),
|
||||
second_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
"[fn:2] A multi-
|
||||
|
||||
line footnote."
|
||||
@ -181,7 +185,9 @@ not in the footnote.",
|
||||
footnote_definition_matcher(input).expect("Parse first footnote_definition");
|
||||
assert_eq!(Into::<&str>::into(remaining), "not in the footnote.");
|
||||
assert_eq!(
|
||||
first_footnote_definition.get_source(),
|
||||
first_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
"[fn:2] A multi-
|
||||
|
||||
line footnote.
|
||||
|
@ -74,7 +74,7 @@ mod tests {
|
||||
use crate::context::List;
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::parser::org_source::OrgSource;
|
||||
use crate::types::Source;
|
||||
use crate::types::GetStandardProperties;
|
||||
|
||||
#[test]
|
||||
fn two_paragraphs() {
|
||||
@ -87,7 +87,13 @@ mod tests {
|
||||
let (remaining, second_paragraph) =
|
||||
paragraph_matcher(remaining).expect("Parse second paragraph.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(first_paragraph.get_source(), "foo bar baz\n\n");
|
||||
assert_eq!(second_paragraph.get_source(), "lorem ipsum");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo bar baz\n\n"
|
||||
);
|
||||
assert_eq!(
|
||||
second_paragraph.get_standard_properties().get_source(),
|
||||
"lorem ipsum"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ mod tests {
|
||||
use crate::context::Context;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::types::Source;
|
||||
use crate::types::GetStandardProperties;
|
||||
|
||||
#[test]
|
||||
fn plain_list_item_empty() {
|
||||
@ -456,7 +456,7 @@ mod tests {
|
||||
let plain_list_item_matcher = parser_with_context!(plain_list_item)(&initial_context);
|
||||
let (remaining, result) = plain_list_item_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.source, "1.");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -468,7 +468,7 @@ mod tests {
|
||||
let plain_list_item_matcher = parser_with_context!(plain_list_item)(&initial_context);
|
||||
let (remaining, result) = plain_list_item_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.source, "1. foo");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -480,7 +480,7 @@ mod tests {
|
||||
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||
let (remaining, result) = plain_list_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.source, "1.");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -492,7 +492,7 @@ mod tests {
|
||||
let plain_list_matcher = parser_with_context!(plain_list)(&initial_context);
|
||||
let (remaining, result) = plain_list_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.source, "1. foo");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -539,7 +539,7 @@ mod tests {
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), " ipsum\n");
|
||||
assert_eq!(
|
||||
result.get_source(),
|
||||
result.get_standard_properties().get_source(),
|
||||
r#"1. foo
|
||||
2. bar
|
||||
baz
|
||||
@ -567,7 +567,7 @@ baz"#,
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "baz");
|
||||
assert_eq!(
|
||||
result.get_source(),
|
||||
result.get_standard_properties().get_source(),
|
||||
r#"1. foo
|
||||
1. bar
|
||||
|
||||
@ -600,7 +600,7 @@ dolar"#,
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "dolar");
|
||||
assert_eq!(
|
||||
result.get_source(),
|
||||
result.get_standard_properties().get_source(),
|
||||
r#"1. foo
|
||||
|
||||
bar
|
||||
|
@ -146,7 +146,7 @@ mod tests {
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::parser::object_parser::detect_standard_set_object_sans_plain_text;
|
||||
use crate::types::Source;
|
||||
use crate::types::GetStandardProperties;
|
||||
|
||||
#[test]
|
||||
fn plain_text_simple() {
|
||||
@ -159,6 +159,9 @@ mod tests {
|
||||
))(&initial_context);
|
||||
let (remaining, result) = map(plain_text_matcher, Object::PlainText)(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.get_source(), Into::<&str>::into(input));
|
||||
assert_eq!(
|
||||
result.get_standard_properties().get_source(),
|
||||
Into::<&str>::into(input)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ mod tests {
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::types::Bold;
|
||||
use crate::types::Element;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::PlainText;
|
||||
use crate::types::Source;
|
||||
|
||||
#[test]
|
||||
fn plain_text_radio_target() {
|
||||
@ -172,7 +172,10 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(first_paragraph.get_source(), "foo bar baz");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo bar baz"
|
||||
);
|
||||
assert_eq!(first_paragraph.children.len(), 3);
|
||||
assert_eq!(
|
||||
first_paragraph
|
||||
@ -208,7 +211,10 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(first_paragraph.get_source(), "foo *bar* baz");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo *bar* baz"
|
||||
);
|
||||
assert_eq!(first_paragraph.children.len(), 3);
|
||||
assert_eq!(
|
||||
first_paragraph
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::Element;
|
||||
use super::GetStandardProperties;
|
||||
use super::Object;
|
||||
use super::Source;
|
||||
use super::StandardProperties;
|
||||
|
||||
pub type PriorityCookie = u8;
|
||||
@ -44,48 +44,21 @@ pub enum TodoKeywordType {
|
||||
Done,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Document<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DocumentElement<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
impl<'s> GetStandardProperties<'s> for DocumentElement<'s> {
|
||||
fn get_standard_properties(&'s self) -> &'s dyn StandardProperties {
|
||||
match self {
|
||||
DocumentElement::Heading(obj) => obj.source,
|
||||
DocumentElement::Section(obj) => obj.source,
|
||||
DocumentElement::Heading(inner) => inner,
|
||||
DocumentElement::Section(inner) => inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Section<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Heading<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for Document<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for DocumentElement<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
DocumentElement::Heading(obj) => obj.source,
|
||||
DocumentElement::Section(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for Section<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
|
@ -19,8 +19,9 @@ use super::lesser_element::Planning;
|
||||
use super::lesser_element::SrcBlock;
|
||||
use super::lesser_element::VerseBlock;
|
||||
use super::Drawer;
|
||||
use super::GetStandardProperties;
|
||||
use super::SetSource;
|
||||
use super::Source;
|
||||
use super::StandardProperties;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Element<'s> {
|
||||
@ -48,35 +49,6 @@ pub enum Element<'s> {
|
||||
LatexEnvironment(LatexEnvironment<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
match self {
|
||||
Element::Paragraph(obj) => obj.get_source(),
|
||||
Element::PlainList(obj) => obj.get_source(),
|
||||
Element::GreaterBlock(obj) => obj.get_source(),
|
||||
Element::DynamicBlock(obj) => obj.get_source(),
|
||||
Element::FootnoteDefinition(obj) => obj.get_source(),
|
||||
Element::Comment(obj) => obj.get_source(),
|
||||
Element::Drawer(obj) => obj.get_source(),
|
||||
Element::PropertyDrawer(obj) => obj.get_source(),
|
||||
Element::Table(obj) => obj.get_source(),
|
||||
Element::VerseBlock(obj) => obj.get_source(),
|
||||
Element::CommentBlock(obj) => obj.get_source(),
|
||||
Element::ExampleBlock(obj) => obj.get_source(),
|
||||
Element::ExportBlock(obj) => obj.get_source(),
|
||||
Element::SrcBlock(obj) => obj.get_source(),
|
||||
Element::Clock(obj) => obj.get_source(),
|
||||
Element::DiarySexp(obj) => obj.get_source(),
|
||||
Element::Planning(obj) => obj.get_source(),
|
||||
Element::FixedWidthArea(obj) => obj.get_source(),
|
||||
Element::HorizontalRule(obj) => obj.get_source(),
|
||||
Element::Keyword(obj) => obj.get_source(),
|
||||
Element::BabelCall(obj) => obj.get_source(),
|
||||
Element::LatexEnvironment(obj) => obj.get_source(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> SetSource<'s> for Element<'s> {
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn set_source(&mut self, source: &'s str) {
|
||||
@ -106,3 +78,32 @@ impl<'s> SetSource<'s> for Element<'s> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> GetStandardProperties<'s> for Element<'s> {
|
||||
fn get_standard_properties(&'s self) -> &'s dyn StandardProperties {
|
||||
match self {
|
||||
Element::Paragraph(inner) => inner,
|
||||
Element::PlainList(inner) => inner,
|
||||
Element::GreaterBlock(inner) => inner,
|
||||
Element::DynamicBlock(inner) => inner,
|
||||
Element::FootnoteDefinition(inner) => inner,
|
||||
Element::Comment(inner) => inner,
|
||||
Element::Drawer(inner) => inner,
|
||||
Element::PropertyDrawer(inner) => inner,
|
||||
Element::Table(inner) => inner,
|
||||
Element::VerseBlock(inner) => inner,
|
||||
Element::CommentBlock(inner) => inner,
|
||||
Element::ExampleBlock(inner) => inner,
|
||||
Element::ExportBlock(inner) => inner,
|
||||
Element::SrcBlock(inner) => inner,
|
||||
Element::Clock(inner) => inner,
|
||||
Element::DiarySexp(inner) => inner,
|
||||
Element::Planning(inner) => inner,
|
||||
Element::FixedWidthArea(inner) => inner,
|
||||
Element::HorizontalRule(inner) => inner,
|
||||
Element::Keyword(inner) => inner,
|
||||
Element::BabelCall(inner) => inner,
|
||||
Element::LatexEnvironment(inner) => inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
src/types/get_standard_properties.rs
Normal file
14
src/types/get_standard_properties.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use super::StandardProperties;
|
||||
|
||||
pub trait GetStandardProperties<'s> {
|
||||
// TODO: Can I eliminate this dynamic dispatch, perhaps using nominal generic structs? Low prioritiy since this is not used during parsing.
|
||||
fn get_standard_properties(&'s self) -> &'s dyn StandardProperties
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
impl<'s, I: StandardProperties<'s>> GetStandardProperties<'s> for I {
|
||||
fn get_standard_properties(&'s self) -> &'s dyn StandardProperties {
|
||||
self
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ use super::element::Element;
|
||||
use super::lesser_element::TableCell;
|
||||
use super::Keyword;
|
||||
use super::Object;
|
||||
use super::Source;
|
||||
use super::StandardProperties;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -86,66 +85,6 @@ pub struct TableRow<'s> {
|
||||
pub children: Vec<TableCell<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainList<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainListItem<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for GreaterBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DynamicBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for FootnoteDefinition<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Drawer<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PropertyDrawer<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for NodeProperty<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Table<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for TableRow<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for PlainList<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
|
@ -1,6 +1,5 @@
|
||||
use super::object::Object;
|
||||
use super::PlainText;
|
||||
use super::Source;
|
||||
use super::StandardProperties;
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -108,92 +107,6 @@ impl<'s> Paragraph<'s> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Paragraph<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for TableCell<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Comment<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for VerseBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for CommentBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for ExampleBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for ExportBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
impl<'s> Source<'s> for SrcBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Clock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for DiarySexp<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Planning<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for FixedWidthArea<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for HorizontalRule<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Keyword<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for LatexEnvironment<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for Paragraph<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
|
@ -1,5 +1,6 @@
|
||||
mod document;
|
||||
mod element;
|
||||
mod get_standard_properties;
|
||||
mod greater_element;
|
||||
mod lesser_element;
|
||||
mod object;
|
||||
@ -13,6 +14,7 @@ pub use document::PriorityCookie;
|
||||
pub use document::Section;
|
||||
pub use document::TodoKeywordType;
|
||||
pub use element::Element;
|
||||
pub use get_standard_properties::GetStandardProperties;
|
||||
pub use greater_element::CheckboxType;
|
||||
pub use greater_element::Drawer;
|
||||
pub use greater_element::DynamicBlock;
|
||||
@ -69,5 +71,4 @@ pub use object::Timestamp;
|
||||
pub use object::Underline;
|
||||
pub use object::Verbatim;
|
||||
pub(crate) use source::SetSource;
|
||||
pub(crate) use source::Source;
|
||||
pub use standard_properties::StandardProperties;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::Source;
|
||||
use super::GetStandardProperties;
|
||||
use super::StandardProperties;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@ -186,202 +186,40 @@ pub struct Timestamp<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Object<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
impl<'s> GetStandardProperties<'s> for Object<'s> {
|
||||
fn get_standard_properties(&'s self) -> &'s dyn StandardProperties {
|
||||
match self {
|
||||
Object::Bold(obj) => obj.source,
|
||||
Object::Italic(obj) => obj.source,
|
||||
Object::Underline(obj) => obj.source,
|
||||
Object::StrikeThrough(obj) => obj.source,
|
||||
Object::Code(obj) => obj.source,
|
||||
Object::Verbatim(obj) => obj.source,
|
||||
Object::PlainText(obj) => obj.source,
|
||||
Object::RegularLink(obj) => obj.source,
|
||||
Object::RadioLink(obj) => obj.source,
|
||||
Object::RadioTarget(obj) => obj.source,
|
||||
Object::PlainLink(obj) => obj.source,
|
||||
Object::AngleLink(obj) => obj.source,
|
||||
Object::OrgMacro(obj) => obj.source,
|
||||
Object::Entity(obj) => obj.source,
|
||||
Object::LatexFragment(obj) => obj.source,
|
||||
Object::ExportSnippet(obj) => obj.source,
|
||||
Object::FootnoteReference(obj) => obj.source,
|
||||
Object::Citation(obj) => obj.source,
|
||||
Object::CitationReference(obj) => obj.source,
|
||||
Object::InlineBabelCall(obj) => obj.source,
|
||||
Object::InlineSourceBlock(obj) => obj.source,
|
||||
Object::LineBreak(obj) => obj.source,
|
||||
Object::Target(obj) => obj.source,
|
||||
Object::Timestamp(obj) => obj.source,
|
||||
Object::StatisticsCookie(obj) => obj.source,
|
||||
Object::Subscript(obj) => obj.source,
|
||||
Object::Superscript(obj) => obj.source,
|
||||
Object::Bold(inner) => inner,
|
||||
Object::Italic(inner) => inner,
|
||||
Object::Underline(inner) => inner,
|
||||
Object::StrikeThrough(inner) => inner,
|
||||
Object::Code(inner) => inner,
|
||||
Object::Verbatim(inner) => inner,
|
||||
Object::PlainText(inner) => inner,
|
||||
Object::RegularLink(inner) => inner,
|
||||
Object::RadioLink(inner) => inner,
|
||||
Object::RadioTarget(inner) => inner,
|
||||
Object::PlainLink(inner) => inner,
|
||||
Object::AngleLink(inner) => inner,
|
||||
Object::OrgMacro(inner) => inner,
|
||||
Object::Entity(inner) => inner,
|
||||
Object::LatexFragment(inner) => inner,
|
||||
Object::ExportSnippet(inner) => inner,
|
||||
Object::FootnoteReference(inner) => inner,
|
||||
Object::Citation(inner) => inner,
|
||||
Object::CitationReference(inner) => inner,
|
||||
Object::InlineBabelCall(inner) => inner,
|
||||
Object::InlineSourceBlock(inner) => inner,
|
||||
Object::LineBreak(inner) => inner,
|
||||
Object::Target(inner) => inner,
|
||||
Object::StatisticsCookie(inner) => inner,
|
||||
Object::Subscript(inner) => inner,
|
||||
Object::Superscript(inner) => inner,
|
||||
Object::Timestamp(inner) => inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Bold<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Italic<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Underline<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for StrikeThrough<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Code<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Verbatim<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for RegularLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for RadioLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for RadioTarget<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for AngleLink<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for OrgMacro<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Entity<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for LatexFragment<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for ExportSnippet<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for FootnoteReference<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Citation<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for CitationReference<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for InlineBabelCall<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for InlineSourceBlock<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for LineBreak<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Target<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for StatisticsCookie<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Subscript<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Superscript<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Timestamp<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PlainText<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> StandardProperties<'s> for Bold<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
|
@ -1,6 +1,3 @@
|
||||
pub(crate) trait Source<'s> {
|
||||
fn get_source(&'s self) -> &'s str;
|
||||
}
|
||||
pub(crate) trait SetSource<'s> {
|
||||
fn set_source(&mut self, source: &'s str);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user