pub use pulldown_typst::{
Bookmarks, CodeBlockDisplay, Event, LinkType, NumberingPattern, QuoteQuotes, QuoteType,
ShowType, TableCellAlignment, TableOfContents, Tag,
};
use crate::ParserEvent;
pub mod to;
pub struct AssertTypst<T>(pub T);
impl<'a, T> Iterator for AssertTypst<T>
where
T: Iterator<Item = ParserEvent<'a>>,
{
type Item = self::Event<'a>;
fn next(&mut self) -> Option<Self::Item> {
match self.0.next() {
None => None,
Some(ParserEvent::Typst(x)) => Some(x),
#[cfg(feature = "markdown")]
Some(ParserEvent::Markdown(x)) => panic!("unexpected markdown event: {x:?}"),
#[cfg(feature = "mdbook")]
Some(ParserEvent::Mdbook(x)) => panic!("unexpected mdbook event: {x:?}"),
}
}
}
pub struct TypstFilter<T>(pub T);
impl<'a, T> Iterator for TypstFilter<T>
where
T: Iterator<Item = ParserEvent<'a>>,
{
type Item = Event<'a>;
fn next(&mut self) -> Option<Self::Item> {
match self.0.next() {
None => None,
Some(ParserEvent::Typst(x)) => Some(x),
#[cfg(feature = "markdown")]
Some(ParserEvent::Markdown(_)) => self.next(),
#[cfg(feature = "mdbook")]
Some(ParserEvent::Mdbook(_)) => self.next(),
}
}
}
pub struct TypstIter<T>(pub T);
impl<'a, T> Iterator for TypstIter<T>
where
T: Iterator<Item = self::Event<'a>>,
{
type Item = ParserEvent<'a>;
fn next(&mut self) -> Option<Self::Item> {
self.0.next().map(ParserEvent::Typst)
}
}