summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/text/misc.rs
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2023-11-06 21:37:50 +0100
committerGitHub <noreply@github.com>2023-11-06 21:37:50 +0100
commitc0f6d2004afebfa9412ba0c2d598ef8287197c42 (patch)
tree4bb034ca671e7d1982a306f5aecfc4f78a01841d /crates/typst-library/src/text/misc.rs
parent8fd546760c7c425398f0114997c8085a481d8d2a (diff)
Content rework 2 - Electric Boogaloo (#2504)
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)))
}
}