Skip to content

Commit 4e46fb1

Browse files
committed
Fix logical ordering of floats and footnotes (#5185)
1 parent 41d8ecd commit 4e46fb1

26 files changed

+458
-320
lines changed

crates/typst/src/foundations/selector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::foundations::{
1010
cast, func, repr, scope, ty, CastInfo, Content, Context, Dict, Element, FromValue,
1111
Func, Label, Reflect, Regex, Repr, Str, StyleChain, Type, Value,
1212
};
13-
use crate::introspection::{Introspector, Locatable, Location};
13+
use crate::introspection::{Introspector, Locatable, Location, Unqueriable};
1414
use crate::symbols::Symbol;
1515

1616
/// A helper macro to create a field selector used in [`Selector::Elem`]
@@ -339,7 +339,7 @@ impl FromValue for LocatableSelector {
339339
fn validate(selector: &Selector) -> StrResult<()> {
340340
match selector {
341341
Selector::Elem(elem, _) => {
342-
if !elem.can::<dyn Locatable>() {
342+
if !elem.can::<dyn Locatable>() || elem.can::<dyn Unqueriable>() {
343343
Err(eco_format!("{} is not locatable", elem.name()))?
344344
}
345345
}

crates/typst/src/introspection/counter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::foundations::{
1212
Element, Func, IntoValue, Label, LocatableSelector, NativeElement, Packed, Repr,
1313
Selector, Show, Smart, Str, StyleChain, Value,
1414
};
15-
use crate::introspection::{Introspector, Locatable, Location};
15+
use crate::introspection::{Introspector, Locatable, Location, Tag};
1616
use crate::layout::{Frame, FrameItem, PageElem};
1717
use crate::math::EquationElem;
1818
use crate::model::{FigureElem, FootnoteElem, HeadingElem, Numbering, NumberingPattern};
@@ -821,8 +821,8 @@ impl ManualPageCounter {
821821
for (_, item) in page.items() {
822822
match item {
823823
FrameItem::Group(group) => self.visit(engine, &group.frame)?,
824-
FrameItem::Tag(tag) => {
825-
let Some(elem) = tag.elem().to_packed::<CounterUpdateElem>() else {
824+
FrameItem::Tag(Tag::Start(elem)) => {
825+
let Some(elem) = elem.to_packed::<CounterUpdateElem>() else {
826826
continue;
827827
};
828828
if *elem.key() == CounterKey::Page {

0 commit comments

Comments
 (0)