blob: 38a5548239d304266a5815019421ac10dae5c2db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use ecow::EcoString;
use typst_utils::singleton;
use crate::foundations::{
elem, Content, NativeElement, Packed, PlainText, Repr, Unlabellable,
};
/// A text space.
#[elem(Unlabellable, PlainText, Repr)]
pub struct SpaceElem {}
impl SpaceElem {
/// Get the globally shared space element.
pub fn shared() -> &'static Content {
singleton!(Content, SpaceElem::new().pack())
}
}
impl Repr for SpaceElem {
fn repr(&self) -> EcoString {
"[ ]".into()
}
}
impl Unlabellable for Packed<SpaceElem> {}
impl PlainText for Packed<SpaceElem> {
fn plain_text(&self, text: &mut EcoString) {
text.push(' ');
}
}
|