parse inline elements

This commit is contained in:
Noah Hellman 2022-11-16 22:11:55 +01:00
parent 8c0abca85f
commit 5aa6d337ff
2 changed files with 88 additions and 0 deletions

87
src/inline.rs Normal file
View file

@ -0,0 +1,87 @@
use crate::Span;
use crate::tree;
use Atom::*;
use Container::*;
pub type Tree = tree::Tree<Container, Atom>;
pub fn parse<I: Iterator<Item = Span>>(src: &str, inlines: I) -> Tree {
Parser::new(src).parse(inlines)
}
pub enum Inline {
Atom(Atom),
Container(Container),
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Atom {
Str,
Softbreak,
Hardbreak,
Escape,
Nbsp,
FootnoteReference,
ExplicitLink,
ReferenceLink,
Emoji,
OpenMarker,
Ellipses,
ImageMarker,
EmDash,
RawFormat,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Container {
// attributes
Attributes,
Span,
// typesetting
Subscript,
Superscript,
Insert,
Delete,
Emph,
Strong,
Mark,
Verbatim,
// smart quoting
SingleQuoted,
DoubleQuoted,
// math
DisplayMath,
InlineMath,
// URLs
Email,
Url,
ImageText,
LinkText,
Reference,
Destination,
}
pub struct Event;
pub struct Parser<'s> {
src: &'s str,
openers: Vec<(Container, usize)>,
events: Vec<(Event, Span)>,
//tree: tree::Builder<Container, Atom>,
}
impl<'s> Parser<'s> {
fn new(src: &'s str) -> Self {
Self {
src,
openers: Vec::new(),
events: Vec::new(),
}
}
fn parse<I: Iterator<Item = Span>>(mut self, inlines: I) -> Tree {
todo!()
}
}

View file

@ -1,4 +1,5 @@
mod block;
mod inline;
mod span;
mod tree;