mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +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 }
|
/// # Locatable elements { #locatable }
|
||||||
/// Currently, only a subset of element functions is locatable. Aside from
|
/// Currently, only a subset of element functions is locatable. Aside from
|
||||||
/// headings and figures, this includes equations, references and all elements
|
/// headings and figures, this includes equations, references, quotes and all
|
||||||
/// with an explicit label. As a result, you _can_ query for e.g. [`strong`]
|
/// elements with an explicit label. As a result, you _can_ query for e.g.
|
||||||
/// elements, but you will find only those that have an explicit label attached
|
/// [`strong`] elements, but you will find only those that have an explicit
|
||||||
/// to them. This limitation will be resolved in the future.
|
/// label attached to them. This limitation will be resolved in the future.
|
||||||
#[ty(scope)]
|
#[ty(scope)]
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
|
||||||
pub struct Location(u128);
|
pub struct Location(u128);
|
||||||
|
@ -4,6 +4,7 @@ use crate::foundations::{
|
|||||||
cast, elem, Content, Depth, Label, NativeElement, Packed, Show, ShowSet, Smart,
|
cast, elem, Content, Depth, Label, NativeElement, Packed, Show, ShowSet, Smart,
|
||||||
StyleChain, Styles,
|
StyleChain, Styles,
|
||||||
};
|
};
|
||||||
|
use crate::introspection::Locatable;
|
||||||
use crate::layout::{
|
use crate::layout::{
|
||||||
Alignment, BlockChild, BlockElem, Em, HElem, PadElem, Spacing, VElem,
|
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.
|
/// flame of Udûn. Go back to the Shadow! You cannot pass.
|
||||||
/// ]
|
/// ]
|
||||||
/// ```
|
/// ```
|
||||||
#[elem(ShowSet, Show)]
|
#[elem(Locatable, ShowSet, Show)]
|
||||||
pub struct QuoteElem {
|
pub struct QuoteElem {
|
||||||
/// Whether this is a block quote.
|
/// 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
|
// New show rules apply to this, but its location and the materialized fields
|
||||||
// from the original are retained.
|
// from the original are retained.
|
||||||
#context query(heading).join()
|
#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