mirror of
https://github.com/typst/typst
synced 2025-05-15 09:35:28 +08:00
32 lines
657 B
Rust
32 lines
657 B
Rust
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(' ');
|
|
}
|
|
}
|