Add span information to realized ParElem (#2675)

This commit is contained in:
Sébastien d'Herbais de Thun 2023-11-15 14:49:29 +01:00 committed by GitHub
parent f56813a778
commit f39a8bc015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -637,7 +637,15 @@ impl<'a> ParBuilder<'a> {
fn finish(self) -> (Content, StyleChain<'a>) {
let (children, shared) = self.0.finish();
(ParElem::new(children.to_vec()).pack(), shared)
// Find the first span that isn't detached.
let span = children
.iter()
.map(|(cnt, _)| cnt.span())
.find(|span| !span.is_detached())
.unwrap_or_else(Span::detached);
(ParElem::new(children.to_vec()).spanned(span).pack(), shared)
}
}

View File

@ -252,7 +252,9 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
// because it will be placed somewhere probably not at the left margin
// it will overflow. So emulate an `hbox` instead and allow the paragraph
// to extend as far as needed.
let span = elem.span();
let frame = ParElem::new(vec![Prehashed::new(elem)])
.spanned(span)
.layout(
self.vt,
self.outer.chain(&self.local),