fixup! e18f24b99d70338014ab8e4031fad9a17b167b8f

This commit is contained in:
Noah Hellman 2022-12-04 17:56:49 +01:00
parent 5755616870
commit 75b13597da
2 changed files with 14 additions and 1 deletions

View file

@ -359,7 +359,16 @@ impl<'s> Iterator for Parser<'s> {
tree::EventKind::Enter(block) => { tree::EventKind::Enter(block) => {
if matches!(block, block::Block::Leaf(l)) { if matches!(block, block::Block::Leaf(l)) {
self.parser = Some(inline::Parser::new()); self.parser = Some(inline::Parser::new());
self.inline_start = ev.span.start(); }
match block {
block::Block::Leaf(block::Leaf::Paragraph) => self.inline_start = ev.span.end(),
block::Block::Leaf(block::Leaf::CodeBlock { .. }) => {
let lang = self.tree.next().unwrap();
self.inline_start = lang.span.end();
let lang = (!lang.span.is_empty()).then(|| lang.span.of(self.src).trim());
return Event::Start(Container::CodeBlock { lang }, Attributes::none());
}
_ => {}
} }
Event::Start(Container::from_block(self.src, block), Attributes::none()) Event::Start(Container::from_block(self.src, block), Attributes::none())
} }

View file

@ -47,6 +47,10 @@ impl Span {
Self::new(self.start(), span.end()) Self::new(self.start(), span.end())
} }
pub fn is_empty(self) -> bool {
self.start == self.end
}
pub fn start(self) -> usize { pub fn start(self) -> usize {
self.start.try_into().unwrap() self.start.try_into().unwrap()
} }