Initial structure for adding support for comments.
This commit is contained in:
parent
cfcf6443ca
commit
1b10b197f2
@ -216,6 +216,7 @@ fn compare_element<'s>(
|
||||
Element::PlainList(obj) => compare_plain_list(source, emacs, obj),
|
||||
Element::GreaterBlock(obj) => compare_greater_block(source, emacs, obj),
|
||||
Element::FootnoteDefinition(obj) => compare_footnote_definition(source, emacs, obj),
|
||||
Element::Comment(obj) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
1
src/parser/comment.rs
Normal file
1
src/parser/comment.rs
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,15 +1,16 @@
|
||||
use super::PlainListItem;
|
||||
use super::error::Res;
|
||||
use super::footnote_definition::footnote_definition;
|
||||
use super::greater_block::greater_block;
|
||||
use super::greater_element::FootnoteDefinition;
|
||||
use super::greater_element::GreaterBlock;
|
||||
use super::greater_element::PlainList;
|
||||
use super::lesser_element::Comment;
|
||||
use super::lesser_element::Paragraph;
|
||||
use super::paragraph::paragraph;
|
||||
use super::plain_list::plain_list;
|
||||
use super::source::Source;
|
||||
use super::Context;
|
||||
use super::PlainListItem;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use nom::branch::alt;
|
||||
use nom::combinator::map;
|
||||
@ -20,6 +21,7 @@ pub enum Element<'s> {
|
||||
PlainList(PlainList<'s>),
|
||||
GreaterBlock(GreaterBlock<'s>),
|
||||
FootnoteDefinition(FootnoteDefinition<'s>),
|
||||
Comment(Comment<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
@ -29,6 +31,7 @@ impl<'s> Source<'s> for Element<'s> {
|
||||
Element::PlainList(obj) => obj.source,
|
||||
Element::GreaterBlock(obj) => obj.source,
|
||||
Element::FootnoteDefinition(obj) => obj.source,
|
||||
Element::Comment(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,6 +66,12 @@ impl<'s> Source<'s> for FootnoteDefinition<'s> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Comment<'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);
|
||||
|
@ -5,3 +5,8 @@ pub struct Paragraph<'s> {
|
||||
pub source: &'s str,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Comment<'s> {
|
||||
pub source: &'s str,
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
mod comment;
|
||||
mod document;
|
||||
mod element;
|
||||
mod error;
|
||||
@ -24,6 +25,7 @@ pub use greater_element::FootnoteDefinition;
|
||||
pub use greater_element::GreaterBlock;
|
||||
pub use greater_element::PlainList;
|
||||
pub use greater_element::PlainListItem;
|
||||
pub use lesser_element::Comment;
|
||||
pub use lesser_element::Paragraph;
|
||||
pub use source::Source;
|
||||
type Context<'r, 's> = &'r parser_context::ContextTree<'r, 's>;
|
||||
|
Loading…
Reference in New Issue
Block a user