Initial structure for drawer.
This commit is contained in:
parent
ea74e329b2
commit
1f7c24545b
@ -218,6 +218,7 @@ fn compare_element<'s>(
|
||||
Element::GreaterBlock(obj) => compare_greater_block(source, emacs, obj),
|
||||
Element::FootnoteDefinition(obj) => compare_footnote_definition(source, emacs, obj),
|
||||
Element::Comment(obj) => compare_comment(source, emacs, obj),
|
||||
Element::Drawer(obj) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
8
src/parser/drawer.rs
Normal file
8
src/parser/drawer.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use super::Context;
|
||||
use crate::parser::error::Res;
|
||||
use crate::parser::Drawer;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn drawer<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Drawer<'s>> {
|
||||
todo!()
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
use super::comment::comment;
|
||||
use super::drawer::drawer;
|
||||
use super::error::Res;
|
||||
use super::footnote_definition::footnote_definition;
|
||||
use super::greater_block::greater_block;
|
||||
@ -11,6 +12,7 @@ use super::paragraph::paragraph;
|
||||
use super::plain_list::plain_list;
|
||||
use super::source::Source;
|
||||
use super::Context;
|
||||
use super::Drawer;
|
||||
use super::PlainListItem;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use nom::branch::alt;
|
||||
@ -23,6 +25,7 @@ pub enum Element<'s> {
|
||||
GreaterBlock(GreaterBlock<'s>),
|
||||
FootnoteDefinition(FootnoteDefinition<'s>),
|
||||
Comment(Comment<'s>),
|
||||
Drawer(Drawer<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
@ -33,6 +36,7 @@ impl<'s> Source<'s> for Element<'s> {
|
||||
Element::GreaterBlock(obj) => obj.source,
|
||||
Element::FootnoteDefinition(obj) => obj.source,
|
||||
Element::Comment(obj) => obj.source,
|
||||
Element::Drawer(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,6 +77,12 @@ impl<'s> Source<'s> for Comment<'s> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Drawer<'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);
|
||||
@ -92,10 +102,12 @@ pub fn non_paragraph_element<'r, 's>(
|
||||
let greater_block_matcher = parser_with_context!(greater_block)(context);
|
||||
let footnote_definition_matcher = parser_with_context!(footnote_definition)(context);
|
||||
let comment_matcher = parser_with_context!(comment)(context);
|
||||
let drawer_matcher = parser_with_context!(drawer)(context);
|
||||
alt((
|
||||
map(plain_list_matcher, Element::PlainList),
|
||||
map(greater_block_matcher, Element::GreaterBlock),
|
||||
map(footnote_definition_matcher, Element::FootnoteDefinition),
|
||||
map(comment_matcher, Element::Comment),
|
||||
map(drawer_matcher, Element::Drawer),
|
||||
))(input)
|
||||
}
|
||||
|
@ -28,3 +28,10 @@ pub struct FootnoteDefinition<'s> {
|
||||
pub label: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Drawer<'s> {
|
||||
pub source: &'s str,
|
||||
pub label: &'s str,
|
||||
pub children: Vec<Element<'s>>,
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
mod comment;
|
||||
mod document;
|
||||
mod drawer;
|
||||
mod element;
|
||||
mod error;
|
||||
mod footnote_definition;
|
||||
@ -21,6 +22,7 @@ pub use document::DocumentElement;
|
||||
pub use document::Heading;
|
||||
pub use document::Section;
|
||||
pub use element::Element;
|
||||
pub use greater_element::Drawer;
|
||||
pub use greater_element::FootnoteDefinition;
|
||||
pub use greater_element::GreaterBlock;
|
||||
pub use greater_element::PlainList;
|
||||
|
Loading…
Reference in New Issue
Block a user