diff --git a/crates/typst/src/introspection/location.rs b/crates/typst/src/introspection/location.rs index 5cd6aae05..70076bcaa 100644 --- a/crates/typst/src/introspection/location.rs +++ b/crates/typst/src/introspection/location.rs @@ -17,10 +17,10 @@ use crate::model::Numbering; /// /// # Locatable elements { #locatable } /// Currently, only a subset of element functions is locatable. Aside from -/// headings and figures, this includes equations, references and all elements -/// with an explicit label. As a result, you _can_ query for e.g. [`strong`] -/// elements, but you will find only those that have an explicit label attached -/// to them. This limitation will be resolved in the future. +/// headings and figures, this includes equations, references, quotes and all +/// elements with an explicit label. As a result, you _can_ query for e.g. +/// [`strong`] elements, but you will find only those that have an explicit +/// label attached to them. This limitation will be resolved in the future. #[ty(scope)] #[derive(Copy, Clone, Eq, PartialEq, Hash)] pub struct Location(u128); diff --git a/crates/typst/src/model/quote.rs b/crates/typst/src/model/quote.rs index ff6ae1108..160d96d62 100644 --- a/crates/typst/src/model/quote.rs +++ b/crates/typst/src/model/quote.rs @@ -4,6 +4,7 @@ use crate::foundations::{ cast, elem, Content, Depth, Label, NativeElement, Packed, Show, ShowSet, Smart, StyleChain, Styles, }; +use crate::introspection::Locatable; use crate::layout::{ Alignment, BlockChild, BlockElem, Em, HElem, PadElem, Spacing, VElem, }; @@ -42,7 +43,7 @@ use crate::text::{SmartQuoteElem, SmartQuotes, SpaceElem, TextElem}; /// flame of Udûn. Go back to the Shadow! You cannot pass. /// ] /// ``` -#[elem(ShowSet, Show)] +#[elem(Locatable, ShowSet, Show)] pub struct QuoteElem { /// Whether this is a block quote. /// diff --git a/tests/ref/query-quote.png b/tests/ref/query-quote.png new file mode 100644 index 000000000..e21365928 Binary files /dev/null and b/tests/ref/query-quote.png differ diff --git a/tests/suite/introspection/query.typ b/tests/suite/introspection/query.typ index 76ecc913d..3d71529e5 100644 --- a/tests/suite/introspection/query.typ +++ b/tests/suite/introspection/query.typ @@ -281,3 +281,19 @@ // New show rules apply to this, but its location and the materialized fields // from the original are retained. #context query(heading).join() + +--- query-quote --- +// Test quoting a query. + +#quote[ABC] & #quote[EFG] + +#context query(selector(quote).before(here())).first() + +#quote(block: true)[HIJ] +#quote(block: true)[KLM] + +#context query(selector(quote).before(here())).last() + +#quote[NOP] + +#context query().first()