feat: [WIP] make more things locatable

skip-checks:true
This commit is contained in:
Tobias Schmitz 2025-05-27 15:55:04 +02:00
parent c8f0e86e75
commit 3f131e9c26
No known key found for this signature in database
23 changed files with 58 additions and 40 deletions

View File

@ -7,6 +7,7 @@ pub use self::dom::*;
use ecow::EcoString; use ecow::EcoString;
use crate::foundations::{elem, Content, Module, Scope}; use crate::foundations::{elem, Content, Module, Scope};
use crate::introspection::Locatable;
/// Create a module with all HTML definitions. /// Create a module with all HTML definitions.
pub fn module() -> Module { pub fn module() -> Module {
@ -38,7 +39,7 @@ pub fn module() -> Module {
/// A div with _Typst content_ inside! /// A div with _Typst content_ inside!
/// ] /// ]
/// ``` /// ```
#[elem(name = "elem")] #[elem(name = "elem", Locatable)]
pub struct HtmlElem { pub struct HtmlElem {
/// The element's tag. /// The element's tag.
#[required] #[required]

View File

@ -388,6 +388,8 @@ impl IntrospectorBuilder {
); );
} }
dbg!(elems.len());
self.finalize(elems) self.finalize(elems)
} }

View File

@ -13,6 +13,7 @@ use crate::foundations::{
cast, elem, scope, Array, CastInfo, Content, Context, Fold, FromValue, Func, cast, elem, scope, Array, CastInfo, Content, Context, Fold, FromValue, Func,
IntoValue, NativeElement, Packed, Reflect, Resolve, Show, Smart, StyleChain, Value, IntoValue, NativeElement, Packed, Reflect, Resolve, Show, Smart, StyleChain, Value,
}; };
use crate::introspection::Locatable;
use crate::layout::{ use crate::layout::{
Alignment, BlockElem, Length, OuterHAlignment, OuterVAlignment, Rel, Sides, Sizing, Alignment, BlockElem, Length, OuterHAlignment, OuterVAlignment, Rel, Sides, Sizing,
}; };
@ -136,7 +137,7 @@ use crate::visualize::{Paint, Stroke};
/// ///
/// Furthermore, strokes of a repeated grid header or footer will take /// Furthermore, strokes of a repeated grid header or footer will take
/// precedence over regular cell strokes. /// precedence over regular cell strokes.
#[elem(scope, Show)] #[elem(scope, Locatable, Show)]
pub struct GridElem { pub struct GridElem {
/// The column sizes. /// The column sizes.
/// ///
@ -462,7 +463,7 @@ impl TryFrom<Content> for GridItem {
/// If `repeat` is set to `true`, the header will be repeated across pages. For /// If `repeat` is set to `true`, the header will be repeated across pages. For
/// an example, refer to the [`table.header`]($table.header) element and the /// an example, refer to the [`table.header`]($table.header) element and the
/// [`grid.stroke`]($grid.stroke) parameter. /// [`grid.stroke`]($grid.stroke) parameter.
#[elem(name = "header", title = "Grid Header")] #[elem(name = "header", title = "Grid Header", Locatable)]
pub struct GridHeader { pub struct GridHeader {
/// Whether this header should be repeated across pages. /// Whether this header should be repeated across pages.
#[default(true)] #[default(true)]
@ -490,7 +491,7 @@ pub struct GridHeader {
/// itself on every page of the table. /// itself on every page of the table.
/// ///
/// No other grid cells may be placed after the footer. /// No other grid cells may be placed after the footer.
#[elem(name = "footer", title = "Grid Footer")] #[elem(name = "footer", title = "Grid Footer", Locatable)]
pub struct GridFooter { pub struct GridFooter {
/// Whether this footer should be repeated across pages. /// Whether this footer should be repeated across pages.
#[default(true)] #[default(true)]
@ -657,7 +658,7 @@ pub struct GridVLine {
/// which allows you, for example, to apply styles based on a cell's position. /// which allows you, for example, to apply styles based on a cell's position.
/// Refer to the examples of the [`table.cell`]($table.cell) element to learn /// Refer to the examples of the [`table.cell`]($table.cell) element to learn
/// more about this. /// more about this.
#[elem(name = "cell", title = "Grid Cell", Show)] #[elem(name = "cell", title = "Grid Cell", Locatable, Show)]
pub struct GridCell { pub struct GridCell {
/// The cell's body. /// The cell's body.
#[required] #[required]

View File

@ -1,6 +1,7 @@
use crate::diag::SourceResult; use crate::diag::SourceResult;
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{elem, Content, Packed, Show, StyleChain}; use crate::foundations::{elem, Content, Packed, Show, StyleChain};
use crate::introspection::Locatable;
/// Hides content without affecting layout. /// Hides content without affecting layout.
/// ///
@ -14,7 +15,7 @@ use crate::foundations::{elem, Content, Packed, Show, StyleChain};
/// Hello Jane \ /// Hello Jane \
/// #hide[Hello] Joe /// #hide[Hello] Joe
/// ``` /// ```
#[elem(Show)] #[elem(Locatable, Show)]
pub struct HideElem { pub struct HideElem {
/// The content to hide. /// The content to hide.
#[required] #[required]

View File

@ -1,6 +1,7 @@
use crate::diag::SourceResult; use crate::diag::SourceResult;
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{elem, Content, NativeElement, Packed, Show, StyleChain}; use crate::foundations::{elem, Content, NativeElement, Packed, Show, StyleChain};
use crate::introspection::Locatable;
use crate::layout::{BlockElem, Length}; use crate::layout::{BlockElem, Length};
/// Repeats content to the available space. /// Repeats content to the available space.
@ -24,7 +25,7 @@ use crate::layout::{BlockElem, Length};
/// Berlin, the 22nd of December, 2022 /// Berlin, the 22nd of December, 2022
/// ] /// ]
/// ``` /// ```
#[elem(Show)] #[elem(Locatable, Show)]
pub struct RepeatElem { pub struct RepeatElem {
/// The content to repeat. /// The content to repeat.
#[required] #[required]

View File

@ -28,6 +28,7 @@ use typst_utils::singleton;
use unicode_math_class::MathClass; use unicode_math_class::MathClass;
use crate::foundations::{elem, Content, Module, NativeElement, Scope}; use crate::foundations::{elem, Content, Module, NativeElement, Scope};
use crate::introspection::Locatable;
use crate::layout::{Em, HElem}; use crate::layout::{Em, HElem};
use crate::text::TextElem; use crate::text::TextElem;
@ -109,7 +110,7 @@ pub fn module() -> Module {
pub trait Mathy {} pub trait Mathy {}
/// A math alignment point: `&`, `&&`. /// A math alignment point: `&`, `&&`.
#[elem(title = "Alignment Point", Mathy)] #[elem(title = "Alignment Point", Mathy, Locatable)]
pub struct AlignPointElem {} pub struct AlignPointElem {}
impl AlignPointElem { impl AlignPointElem {
@ -136,7 +137,7 @@ impl AlignPointElem {
/// ///
/// $x loves y and y loves 5$ /// $x loves y and y loves 5$
/// ``` /// ```
#[elem(Mathy)] #[elem(Mathy, Locatable)]
pub struct ClassElem { pub struct ClassElem {
/// The class to apply to the content. /// The class to apply to the content.
#[required] #[required]

View File

@ -1,6 +1,7 @@
use typst_syntax::Span; use typst_syntax::Span;
use crate::foundations::{elem, func, Content, NativeElement}; use crate::foundations::{elem, func, Content, NativeElement};
use crate::introspection::Locatable;
use crate::math::Mathy; use crate::math::Mathy;
/// A square root. /// A square root.
@ -22,7 +23,7 @@ pub fn sqrt(
/// ```example /// ```example
/// $ root(3, x) $ /// $ root(3, x) $
/// ``` /// ```
#[elem(Mathy)] #[elem(Mathy, Locatable)]
pub struct RootElem { pub struct RootElem {
/// Which root of the radicand to take. /// Which root of the radicand to take.
#[positional] #[positional]

View File

@ -43,7 +43,7 @@ use crate::text::{Lang, Region, TextElem};
/// This function indirectly has dedicated syntax. [References]($ref) can be /// This function indirectly has dedicated syntax. [References]($ref) can be
/// used to cite works from the bibliography. The label then corresponds to the /// used to cite works from the bibliography. The label then corresponds to the
/// citation key. /// citation key.
#[elem(Synthesize)] #[elem(Locatable, Synthesize)]
pub struct CiteElem { pub struct CiteElem {
/// The citation key that identifies the entry in the bibliography that /// The citation key that identifies the entry in the bibliography that
/// shall be cited, as a label. /// shall be cited, as a label.

View File

@ -4,6 +4,7 @@ use crate::foundations::{
elem, Content, NativeElement, Packed, Show, StyleChain, TargetElem, elem, Content, NativeElement, Packed, Show, StyleChain, TargetElem,
}; };
use crate::html::{tag, HtmlElem}; use crate::html::{tag, HtmlElem};
use crate::introspection::Locatable;
use crate::text::{ItalicToggle, TextElem}; use crate::text::{ItalicToggle, TextElem};
/// Emphasizes content by toggling italics. /// Emphasizes content by toggling italics.
@ -29,7 +30,7 @@ use crate::text::{ItalicToggle, TextElem};
/// This function also has dedicated syntax: To emphasize content, simply /// This function also has dedicated syntax: To emphasize content, simply
/// enclose it in underscores (`_`). Note that this only works at word /// enclose it in underscores (`_`). Note that this only works at word
/// boundaries. To emphasize part of a word, you have to use the function. /// boundaries. To emphasize part of a word, you have to use the function.
#[elem(title = "Emphasis", keywords = ["italic"], Show)] #[elem(title = "Emphasis", keywords = ["italic"], Locatable, Show)]
pub struct EmphElem { pub struct EmphElem {
/// The content to emphasize. /// The content to emphasize.
#[required] #[required]

View File

@ -10,6 +10,7 @@ use crate::foundations::{
Styles, TargetElem, Styles, TargetElem,
}; };
use crate::html::{attr, tag, HtmlElem}; use crate::html::{attr, tag, HtmlElem};
use crate::introspection::Locatable;
use crate::layout::{Alignment, BlockElem, Em, HAlignment, Length, VAlignment, VElem}; use crate::layout::{Alignment, BlockElem, Em, HAlignment, Length, VAlignment, VElem};
use crate::model::{ use crate::model::{
ListItemLike, ListLike, Numbering, NumberingPattern, ParElem, ParbreakElem, ListItemLike, ListLike, Numbering, NumberingPattern, ParElem, ParbreakElem,
@ -71,7 +72,7 @@ use crate::model::{
/// Enumeration items can contain multiple paragraphs and other block-level /// Enumeration items can contain multiple paragraphs and other block-level
/// content. All content that is indented more than an item's marker becomes /// content. All content that is indented more than an item's marker becomes
/// part of that item. /// part of that item.
#[elem(scope, title = "Numbered List", Show)] #[elem(scope, title = "Numbered List", Locatable, Show)]
pub struct EnumElem { pub struct EnumElem {
/// Defines the default [spacing]($enum.spacing) of the enumeration. If it /// Defines the default [spacing]($enum.spacing) of the enumeration. If it
/// is `{false}`, the items are spaced apart with /// is `{false}`, the items are spaced apart with
@ -271,7 +272,7 @@ impl Show for Packed<EnumElem> {
} }
/// An enumeration item. /// An enumeration item.
#[elem(name = "item", title = "Numbered List Item")] #[elem(name = "item", title = "Numbered List Item", Locatable)]
pub struct EnumItem { pub struct EnumItem {
/// The item's number. /// The item's number.
#[positional] #[positional]

View File

@ -473,7 +473,7 @@ impl Outlinable for Packed<FigureElem> {
/// caption: [A rectangle], /// caption: [A rectangle],
/// ) /// )
/// ``` /// ```
#[elem(name = "caption", Synthesize, Show)] #[elem(name = "caption", Locatable, Synthesize, Show)]
pub struct FigureCaption { pub struct FigureCaption {
/// The caption's position in the figure. Either `{top}` or `{bottom}`. /// The caption's position in the figure. Either `{top}` or `{bottom}`.
/// ///

View File

@ -192,7 +192,7 @@ cast! {
/// page run is a sequence of pages without an explicit pagebreak in between). /// page run is a sequence of pages without an explicit pagebreak in between).
/// For this reason, set and show rules for footnote entries should be defined /// For this reason, set and show rules for footnote entries should be defined
/// before any page content, typically at the very start of the document. /// before any page content, typically at the very start of the document.
#[elem(name = "entry", title = "Footnote Entry", Show, ShowSet)] #[elem(name = "entry", title = "Footnote Entry", Locatable, Show, ShowSet)]
pub struct FootnoteEntry { pub struct FootnoteEntry {
/// The footnote for this entry. Its location can be used to determine /// The footnote for this entry. Its location can be used to determine
/// the footnote counter state. /// the footnote counter state.

View File

@ -9,7 +9,7 @@ use crate::foundations::{
StyleChain, Styles, TargetElem, StyleChain, Styles, TargetElem,
}; };
use crate::html::{attr, tag, HtmlElem}; use crate::html::{attr, tag, HtmlElem};
use crate::introspection::Location; use crate::introspection::{Locatable, Location};
use crate::layout::Position; use crate::layout::Position;
use crate::text::TextElem; use crate::text::TextElem;
@ -38,7 +38,7 @@ use crate::text::TextElem;
/// # Syntax /// # Syntax
/// This function also has dedicated syntax: Text that starts with `http://` or /// This function also has dedicated syntax: Text that starts with `http://` or
/// `https://` is automatically turned into a link. /// `https://` is automatically turned into a link.
#[elem(Show)] #[elem(Locatable, Show)]
pub struct LinkElem { pub struct LinkElem {
/// The destination the link points to. /// The destination the link points to.
/// ///

View File

@ -7,6 +7,7 @@ use crate::foundations::{
Smart, StyleChain, Styles, TargetElem, Value, Smart, StyleChain, Styles, TargetElem, Value,
}; };
use crate::html::{tag, HtmlElem}; use crate::html::{tag, HtmlElem};
use crate::introspection::Locatable;
use crate::layout::{BlockElem, Em, Length, VElem}; use crate::layout::{BlockElem, Em, Length, VElem};
use crate::model::{ParElem, ParbreakElem}; use crate::model::{ParElem, ParbreakElem};
use crate::text::TextElem; use crate::text::TextElem;
@ -42,7 +43,7 @@ use crate::text::TextElem;
/// followed by a space to create a list item. A list item can contain multiple /// followed by a space to create a list item. A list item can contain multiple
/// paragraphs and other block-level content. All content that is indented /// paragraphs and other block-level content. All content that is indented
/// more than an item's marker becomes part of that item. /// more than an item's marker becomes part of that item.
#[elem(scope, title = "Bullet List", Show)] #[elem(scope, title = "Bullet List", Locatable, Show)]
pub struct ListElem { pub struct ListElem {
/// Defines the default [spacing]($list.spacing) of the list. If it is /// Defines the default [spacing]($list.spacing) of the list. If it is
/// `{false}`, the items are spaced apart with /// `{false}`, the items are spaced apart with
@ -178,7 +179,7 @@ impl Show for Packed<ListElem> {
} }
/// A bullet list item. /// A bullet list item.
#[elem(name = "item", title = "Bullet List Item")] #[elem(name = "item", title = "Bullet List Item", Locatable)]
pub struct ListItem { pub struct ListItem {
/// The item's body. /// The item's body.
#[required] #[required]

View File

@ -368,7 +368,7 @@ pub trait Outlinable: Refable {
/// With show-set and show rules on outline entries, you can richly customize /// With show-set and show rules on outline entries, you can richly customize
/// the outline's appearance. See the /// the outline's appearance. See the
/// [section on styling the outline]($outline/#styling-the-outline) for details. /// [section on styling the outline]($outline/#styling-the-outline) for details.
#[elem(scope, name = "entry", title = "Outline Entry", Show)] #[elem(scope, name = "entry", title = "Outline Entry", Locatable, Show)]
pub struct OutlineEntry { pub struct OutlineEntry {
/// The nesting level of this outline entry. Starts at `{1}` for top-level /// The nesting level of this outline entry. Starts at `{1}` for top-level
/// entries. /// entries.

View File

@ -93,7 +93,7 @@ use crate::model::Numbering;
/// let $a$ be the smallest of the /// let $a$ be the smallest of the
/// three integers. Then, we ... /// three integers. Then, we ...
/// ``` /// ```
#[elem(scope, title = "Paragraph")] #[elem(scope, title = "Paragraph", Locatable)]
pub struct ParElem { pub struct ParElem {
/// The spacing between lines. /// The spacing between lines.
/// ///

View File

@ -4,6 +4,7 @@ use crate::foundations::{
elem, Content, NativeElement, Packed, Show, StyleChain, TargetElem, elem, Content, NativeElement, Packed, Show, StyleChain, TargetElem,
}; };
use crate::html::{tag, HtmlElem}; use crate::html::{tag, HtmlElem};
use crate::introspection::Locatable;
use crate::text::{TextElem, WeightDelta}; use crate::text::{TextElem, WeightDelta};
/// Strongly emphasizes content by increasing the font weight. /// Strongly emphasizes content by increasing the font weight.
@ -24,7 +25,7 @@ use crate::text::{TextElem, WeightDelta};
/// simply enclose it in stars/asterisks (`*`). Note that this only works at /// simply enclose it in stars/asterisks (`*`). Note that this only works at
/// word boundaries. To strongly emphasize part of a word, you have to use the /// word boundaries. To strongly emphasize part of a word, you have to use the
/// function. /// function.
#[elem(title = "Strong Emphasis", keywords = ["bold", "weight"], Show)] #[elem(title = "Strong Emphasis", keywords = ["bold", "weight"], Locatable, Show)]
pub struct StrongElem { pub struct StrongElem {
/// The delta to apply on the font weight. /// The delta to apply on the font weight.
/// ///

View File

@ -10,7 +10,7 @@ use crate::foundations::{
TargetElem, TargetElem,
}; };
use crate::html::{attr, tag, HtmlAttrs, HtmlElem, HtmlTag}; use crate::html::{attr, tag, HtmlAttrs, HtmlElem, HtmlTag};
use crate::introspection::Locator; use crate::introspection::{Locatable, Locator};
use crate::layout::grid::resolve::{table_to_cellgrid, Cell, CellGrid, Entry}; use crate::layout::grid::resolve::{table_to_cellgrid, Cell, CellGrid, Entry};
use crate::layout::{ use crate::layout::{
show_grid_cell, Abs, Alignment, BlockElem, Celled, GridCell, GridFooter, GridHLine, show_grid_cell, Abs, Alignment, BlockElem, Celled, GridCell, GridFooter, GridHLine,
@ -121,7 +121,7 @@ use crate::visualize::{Paint, Stroke};
/// [Robert], b, a, b, /// [Robert], b, a, b,
/// ) /// )
/// ``` /// ```
#[elem(scope, Show, LocalName, Figurable)] #[elem(scope, Locatable, Show, LocalName, Figurable)]
pub struct TableElem { pub struct TableElem {
/// The column sizes. See the [grid documentation]($grid) for more /// The column sizes. See the [grid documentation]($grid) for more
/// information on track sizing. /// information on track sizing.
@ -531,7 +531,7 @@ impl TryFrom<Content> for TableItem {
/// [7.34], [57], [2], /// [7.34], [57], [2],
/// ) /// )
/// ``` /// ```
#[elem(name = "header", title = "Table Header")] #[elem(name = "header", title = "Table Header", Locatable)]
pub struct TableHeader { pub struct TableHeader {
/// Whether this header should be repeated across pages. /// Whether this header should be repeated across pages.
#[default(true)] #[default(true)]
@ -561,7 +561,7 @@ pub struct TableHeader {
/// totals, or other information that should be visible on every page. /// totals, or other information that should be visible on every page.
/// ///
/// No other table cells may be placed after the footer. /// No other table cells may be placed after the footer.
#[elem(name = "footer", title = "Table Footer")] #[elem(name = "footer", title = "Table Footer", Locatable)]
pub struct TableFooter { pub struct TableFooter {
/// Whether this footer should be repeated across pages. /// Whether this footer should be repeated across pages.
#[default(true)] #[default(true)]
@ -604,7 +604,7 @@ pub struct TableFooter {
/// [19:00], [Day 1 Attendee Mixer], /// [19:00], [Day 1 Attendee Mixer],
/// ) /// )
/// ``` /// ```
#[elem(name = "hline", title = "Table Horizontal Line")] #[elem(name = "hline", title = "Table Horizontal Line", Locatable)]
pub struct TableHLine { pub struct TableHLine {
/// The row above which the horizontal line is placed (zero-indexed). /// The row above which the horizontal line is placed (zero-indexed).
/// Functions identically to the `y` field in [`grid.hline`]($grid.hline.y). /// Functions identically to the `y` field in [`grid.hline`]($grid.hline.y).
@ -649,7 +649,7 @@ pub struct TableHLine {
/// use the [table's `stroke`]($table.stroke) field or [`table.cell`'s /// use the [table's `stroke`]($table.stroke) field or [`table.cell`'s
/// `stroke`]($table.cell.stroke) field instead if the line you want to place is /// `stroke`]($table.cell.stroke) field instead if the line you want to place is
/// part of all your tables' designs. /// part of all your tables' designs.
#[elem(name = "vline", title = "Table Vertical Line")] #[elem(name = "vline", title = "Table Vertical Line", Locatable)]
pub struct TableVLine { pub struct TableVLine {
/// The column before which the horizontal line is placed (zero-indexed). /// The column before which the horizontal line is placed (zero-indexed).
/// Functions identically to the `x` field in [`grid.vline`]($grid.vline). /// Functions identically to the `x` field in [`grid.vline`]($grid.vline).
@ -770,7 +770,7 @@ pub struct TableVLine {
/// [Vikram], [49], [Perseverance], /// [Vikram], [49], [Perseverance],
/// ) /// )
/// ``` /// ```
#[elem(name = "cell", title = "Table Cell", Show)] #[elem(name = "cell", title = "Table Cell", Locatable, Show)]
pub struct TableCell { pub struct TableCell {
/// The cell's body. /// The cell's body.
#[required] #[required]

View File

@ -7,6 +7,7 @@ use crate::foundations::{
Styles, TargetElem, Styles, TargetElem,
}; };
use crate::html::{tag, HtmlElem}; use crate::html::{tag, HtmlElem};
use crate::introspection::Locatable;
use crate::layout::{Em, HElem, Length, Sides, StackChild, StackElem, VElem}; use crate::layout::{Em, HElem, Length, Sides, StackChild, StackElem, VElem};
use crate::model::{ListItemLike, ListLike, ParElem, ParbreakElem}; use crate::model::{ListItemLike, ListLike, ParElem, ParbreakElem};
use crate::text::TextElem; use crate::text::TextElem;
@ -27,7 +28,7 @@ use crate::text::TextElem;
/// # Syntax /// # Syntax
/// This function also has dedicated syntax: Starting a line with a slash, /// This function also has dedicated syntax: Starting a line with a slash,
/// followed by a term, a colon and a description creates a term list item. /// followed by a term, a colon and a description creates a term list item.
#[elem(scope, title = "Term List", Show)] #[elem(scope, title = "Term List", Locatable, Show)]
pub struct TermsElem { pub struct TermsElem {
/// Defines the default [spacing]($terms.spacing) of the term list. If it is /// Defines the default [spacing]($terms.spacing) of the term list. If it is
/// `{false}`, the items are spaced apart with /// `{false}`, the items are spaced apart with
@ -205,7 +206,7 @@ impl Show for Packed<TermsElem> {
} }
/// A term list item. /// A term list item.
#[elem(name = "item", title = "Term List Item")] #[elem(name = "item", title = "Term List Item", Locatable)]
pub struct TermItem { pub struct TermItem {
/// The term described by the list item. /// The term described by the list item.
#[required] #[required]

View File

@ -3,6 +3,7 @@ use smallvec::smallvec;
use crate::diag::SourceResult; use crate::diag::SourceResult;
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{elem, Content, Packed, Show, Smart, StyleChain}; use crate::foundations::{elem, Content, Packed, Show, Smart, StyleChain};
use crate::introspection::Locatable;
use crate::layout::{Abs, Corners, Length, Rel, Sides}; use crate::layout::{Abs, Corners, Length, Rel, Sides};
use crate::text::{BottomEdge, BottomEdgeMetric, TextElem, TopEdge, TopEdgeMetric}; use crate::text::{BottomEdge, BottomEdgeMetric, TextElem, TopEdge, TopEdgeMetric};
use crate::visualize::{Color, FixedStroke, Paint, Stroke}; use crate::visualize::{Color, FixedStroke, Paint, Stroke};
@ -13,7 +14,7 @@ use crate::visualize::{Color, FixedStroke, Paint, Stroke};
/// ```example /// ```example
/// This is #underline[important]. /// This is #underline[important].
/// ``` /// ```
#[elem(Show)] #[elem(Locatable, Show)]
pub struct UnderlineElem { pub struct UnderlineElem {
/// How to [stroke] the line. /// How to [stroke] the line.
/// ///
@ -99,7 +100,7 @@ impl Show for Packed<UnderlineElem> {
/// ```example /// ```example
/// #overline[A line over text.] /// #overline[A line over text.]
/// ``` /// ```
#[elem(Show)] #[elem(Locatable, Show)]
pub struct OverlineElem { pub struct OverlineElem {
/// How to [stroke] the line. /// How to [stroke] the line.
/// ///
@ -191,7 +192,7 @@ impl Show for Packed<OverlineElem> {
/// ```example /// ```example
/// This is #strike[not] relevant. /// This is #strike[not] relevant.
/// ``` /// ```
#[elem(title = "Strikethrough", Show)] #[elem(title = "Strikethrough", Locatable, Show)]
pub struct StrikeElem { pub struct StrikeElem {
/// How to [stroke] the line. /// How to [stroke] the line.
/// ///
@ -268,7 +269,7 @@ impl Show for Packed<StrikeElem> {
/// ```example /// ```example
/// This is #highlight[important]. /// This is #highlight[important].
/// ``` /// ```
#[elem(Show)] #[elem(Locatable, Show)]
pub struct HighlightElem { pub struct HighlightElem {
/// The color to highlight the text with. /// The color to highlight the text with.
/// ///

View File

@ -20,6 +20,7 @@ use crate::foundations::{
PlainText, Show, ShowSet, Smart, StyleChain, Styles, Synthesize, TargetElem, PlainText, Show, ShowSet, Smart, StyleChain, Styles, Synthesize, TargetElem,
}; };
use crate::html::{tag, HtmlElem}; use crate::html::{tag, HtmlElem};
use crate::introspection::Locatable;
use crate::layout::{BlockBody, BlockElem, Em, HAlignment}; use crate::layout::{BlockBody, BlockElem, Em, HAlignment};
use crate::loading::{DataSource, Load}; use crate::loading::{DataSource, Load};
use crate::model::{Figurable, ParElem}; use crate::model::{Figurable, ParElem};
@ -78,6 +79,7 @@ use crate::World;
scope, scope,
title = "Raw Text / Code", title = "Raw Text / Code",
Synthesize, Synthesize,
Locatable,
Show, Show,
ShowSet, ShowSet,
LocalName, LocalName,
@ -636,7 +638,7 @@ fn format_theme_error(error: syntect::LoadingError) -> LoadError {
/// It allows you to access various properties of the line, such as the line /// It allows you to access various properties of the line, such as the line
/// number, the raw non-highlighted text, the highlighted text, and whether it /// number, the raw non-highlighted text, the highlighted text, and whether it
/// is the first or last line of the raw block. /// is the first or last line of the raw block.
#[elem(name = "line", title = "Raw Text / Code Line", Show, PlainText)] #[elem(name = "line", title = "Raw Text / Code Line", Locatable, Show, PlainText)]
pub struct RawLine { pub struct RawLine {
/// The line number of the raw line inside of the raw block, starts at 1. /// The line number of the raw line inside of the raw block, starts at 1.
#[required] #[required]

View File

@ -3,6 +3,7 @@ use ecow::EcoString;
use crate::diag::SourceResult; use crate::diag::SourceResult;
use crate::engine::Engine; use crate::engine::Engine;
use crate::foundations::{elem, Content, Packed, SequenceElem, Show, StyleChain}; use crate::foundations::{elem, Content, Packed, SequenceElem, Show, StyleChain};
use crate::introspection::Locatable;
use crate::layout::{Em, Length}; use crate::layout::{Em, Length};
use crate::text::{variant, SpaceElem, TextElem, TextSize}; use crate::text::{variant, SpaceElem, TextElem, TextSize};
use crate::World; use crate::World;
@ -15,7 +16,7 @@ use crate::World;
/// ```example /// ```example
/// Revenue#sub[yearly] /// Revenue#sub[yearly]
/// ``` /// ```
#[elem(title = "Subscript", Show)] #[elem(title = "Subscript", Locatable, Show)]
pub struct SubElem { pub struct SubElem {
/// Whether to prefer the dedicated subscript characters of the font. /// Whether to prefer the dedicated subscript characters of the font.
/// ///
@ -74,7 +75,7 @@ impl Show for Packed<SubElem> {
/// ```example /// ```example
/// 1#super[st] try! /// 1#super[st] try!
/// ``` /// ```
#[elem(title = "Superscript", Show)] #[elem(title = "Superscript", Locatable, Show)]
pub struct SuperElem { pub struct SuperElem {
/// Whether to prefer the dedicated superscript characters of the font. /// Whether to prefer the dedicated superscript characters of the font.
/// ///

View File

@ -21,6 +21,7 @@ use crate::foundations::{
cast, elem, func, scope, Bytes, Cast, Content, Derived, NativeElement, Packed, Show, cast, elem, func, scope, Bytes, Cast, Content, Derived, NativeElement, Packed, Show,
Smart, StyleChain, Smart, StyleChain,
}; };
use crate::introspection::Locatable;
use crate::layout::{BlockElem, Length, Rel, Sizing}; use crate::layout::{BlockElem, Length, Rel, Sizing};
use crate::loading::{DataSource, Load, LoadSource, Loaded, Readable}; use crate::loading::{DataSource, Load, LoadSource, Loaded, Readable};
use crate::model::Figurable; use crate::model::Figurable;
@ -44,7 +45,7 @@ use crate::text::LocalName;
/// ], /// ],
/// ) /// )
/// ``` /// ```
#[elem(scope, Show, LocalName, Figurable)] #[elem(scope, Locatable, Show, LocalName, Figurable)]
pub struct ImageElem { pub struct ImageElem {
/// A [path]($syntax/#paths) to an image file or raw bytes making up an /// A [path]($syntax/#paths) to an image file or raw bytes making up an
/// image in one of the supported [formats]($image.format). /// image in one of the supported [formats]($image.format).