mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Make QuoteElem
locatable (#4909)
This commit is contained in:
parent
4cddb48584
commit
40fcd97d58
@ -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);
|
||||
|
@ -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.
|
||||
///
|
||||
|
BIN
tests/ref/query-quote.png
Normal file
BIN
tests/ref/query-quote.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -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] <nop>
|
||||
|
||||
#context query(<nop>).first()
|
||||
|
Loading…
x
Reference in New Issue
Block a user