parse inline elements
This commit is contained in:
parent
8c0abca85f
commit
5aa6d337ff
2 changed files with 88 additions and 0 deletions
87
src/inline.rs
Normal file
87
src/inline.rs
Normal 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!()
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
mod block;
|
||||
mod inline;
|
||||
mod span;
|
||||
mod tree;
|
||||
|
||||
|
|
Loading…
Reference in a new issue