Initial code structure for property drawers.
This commit is contained in:
@@ -8,6 +8,7 @@ use super::greater_element::DynamicBlock;
|
||||
use super::greater_element::FootnoteDefinition;
|
||||
use super::greater_element::GreaterBlock;
|
||||
use super::greater_element::PlainList;
|
||||
use super::greater_element::PropertyDrawer;
|
||||
use super::lesser_element::Comment;
|
||||
use super::lesser_element::Paragraph;
|
||||
use super::paragraph::paragraph;
|
||||
@@ -29,6 +30,7 @@ pub enum Element<'s> {
|
||||
FootnoteDefinition(FootnoteDefinition<'s>),
|
||||
Comment(Comment<'s>),
|
||||
Drawer(Drawer<'s>),
|
||||
PropertyDrawer(PropertyDrawer<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
@@ -41,6 +43,7 @@ impl<'s> Source<'s> for Element<'s> {
|
||||
Element::FootnoteDefinition(obj) => obj.source,
|
||||
Element::Comment(obj) => obj.source,
|
||||
Element::Drawer(obj) => obj.source,
|
||||
Element::PropertyDrawer(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +96,12 @@ impl<'s> Source<'s> for Drawer<'s> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for PropertyDrawer<'s> {
|
||||
fn get_source(&'s self) -> &'s str {
|
||||
self.source
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn element<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Element<'s>> {
|
||||
let non_paragraph_matcher = parser_with_context!(non_paragraph_element)(context);
|
||||
|
||||
@@ -43,3 +43,10 @@ pub struct Drawer<'s> {
|
||||
pub name: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PropertyDrawer<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ mod parser_context;
|
||||
mod parser_with_context;
|
||||
mod plain_list;
|
||||
mod plain_text;
|
||||
mod property_drawer;
|
||||
mod source;
|
||||
mod util;
|
||||
pub use document::document;
|
||||
@@ -30,6 +31,7 @@ pub use greater_element::FootnoteDefinition;
|
||||
pub use greater_element::GreaterBlock;
|
||||
pub use greater_element::PlainList;
|
||||
pub use greater_element::PlainListItem;
|
||||
pub use greater_element::PropertyDrawer;
|
||||
pub use lesser_element::Comment;
|
||||
pub use lesser_element::Paragraph;
|
||||
pub use source::Source;
|
||||
|
||||
11
src/parser/property_drawer.rs
Normal file
11
src/parser/property_drawer.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use super::Context;
|
||||
use crate::parser::error::Res;
|
||||
use crate::parser::greater_element::PropertyDrawer;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn property_drawer<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, PropertyDrawer<'s>> {
|
||||
todo!()
|
||||
}
|
||||
Reference in New Issue
Block a user