summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/text/misc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src/text/misc.rs')
-rw-r--r--crates/typst-library/src/text/misc.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/typst-library/src/text/misc.rs b/crates/typst-library/src/text/misc.rs
index 73657345..9f768f11 100644
--- a/crates/typst-library/src/text/misc.rs
+++ b/crates/typst-library/src/text/misc.rs
@@ -2,9 +2,15 @@ use super::TextElem;
use crate::prelude::*;
/// A text space.
-#[elem(Behave, Unlabellable, PlainText)]
+#[elem(Behave, Unlabellable, PlainText, Repr)]
pub struct SpaceElem {}
+impl Repr for SpaceElem {
+ fn repr(&self) -> EcoString {
+ EcoString::inline("[ ]")
+ }
+}
+
impl Behave for SpaceElem {
fn behaviour(&self) -> Behaviour {
Behaviour::Weak(2)
@@ -98,7 +104,10 @@ pub struct StrongElem {
impl Show for StrongElem {
#[tracing::instrument(name = "StrongElem::show", skip_all)]
fn show(&self, _: &mut Vt, styles: StyleChain) -> SourceResult<Content> {
- Ok(self.body().styled(TextElem::set_delta(Delta(self.delta(styles)))))
+ Ok(self
+ .body()
+ .clone()
+ .styled(TextElem::set_delta(Delta(self.delta(styles)))))
}
}
@@ -153,7 +162,7 @@ pub struct EmphElem {
impl Show for EmphElem {
#[tracing::instrument(name = "EmphElem::show", skip(self))]
fn show(&self, _: &mut Vt, _: StyleChain) -> SourceResult<Content> {
- Ok(self.body().styled(TextElem::set_emph(Toggle)))
+ Ok(self.body().clone().styled(TextElem::set_emph(Toggle)))
}
}