diff --git a/crates/typst/src/text/mod.rs b/crates/typst/src/text/mod.rs index e55a35a68a35..21fa0832bed4 100644 --- a/crates/typst/src/text/mod.rs +++ b/crates/typst/src/text/mod.rs @@ -66,10 +66,10 @@ pub(super) fn define(global: &mut Scope) { global.define_elem::(); global.define_elem::(); global.define_elem::(); + global.define_elem::(); global.define_elem::(); global.define_func::(); global.define_func::(); - global.define_func::(); global.define_func::(); } diff --git a/crates/typst/src/text/smallcaps.rs b/crates/typst/src/text/smallcaps.rs index b41fdf02c742..8bc44498c459 100644 --- a/crates/typst/src/text/smallcaps.rs +++ b/crates/typst/src/text/smallcaps.rs @@ -1,4 +1,6 @@ -use crate::foundations::{func, Content}; +use crate::diag::SourceResult; +use crate::engine::Engine; +use crate::foundations::{elem, Content, Packed, Show, StyleChain}; use crate::text::TextElem; /// Displays text in small capitals. @@ -23,10 +25,15 @@ use crate::text::TextElem; /// = Introduction /// #lorem(40) /// ``` -#[func(title = "Small Capitals")] -pub fn smallcaps( - /// The text to display to small capitals. - body: Content, -) -> Content { - body.styled(TextElem::set_smallcaps(true)) +#[elem(name = "smallcaps", title = "Small Capitals", Show)] +pub struct SmallCapsElem { + #[required] + pub body: Content, +} + +impl Show for Packed { + #[typst_macros::time(name = "smallcaps", span = self.span())] + fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult { + Ok(self.body().clone().styled(TextElem::set_smallcaps(true))) + } }