typst_library/introspection/metadata.rs
1use crate::foundations::{Value, elem};
2use crate::introspection::Locatable;
3
4/// Exposes a value to the query system without producing visible content.
5///
6/// This element can be retrieved with the @query function and from the command
7/// line with @query:command-line-queries[`typst query`]. Its purpose is to
8/// expose an arbitrary value to the introspection system. To identify a
9/// metadata value among others, you can attach a @label to it and query for
10/// that label.
11///
12/// The `metadata` element is especially useful for command line queries because
13/// it allows you to expose arbitrary values to the outside world.
14///
15/// ```example
16/// // Put metadata somewhere.
17/// #metadata("This is a note") <note>
18///
19/// // And find it from anywhere else.
20/// #context {
21/// query(<note>).first().value
22/// }
23/// ```
24#[elem(Locatable)]
25pub struct MetadataElem {
26 /// The value to embed into the document.
27 #[required]
28 pub value: Value,
29}