mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
Fix symbol repr
This commit is contained in:
parent
7dd3523044
commit
3fba007c13
@ -310,7 +310,7 @@ impl Debug for List {
|
|||||||
impl crate::foundations::Repr for Symbol {
|
impl crate::foundations::Repr for Symbol {
|
||||||
fn repr(&self) -> EcoString {
|
fn repr(&self) -> EcoString {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
Repr::Single(c) => eco_format!("symbol(\"{}\")", *c),
|
Repr::Single(value) => eco_format!("symbol({})", value.repr()),
|
||||||
Repr::Complex(variants) => {
|
Repr::Complex(variants) => {
|
||||||
eco_format!(
|
eco_format!(
|
||||||
"symbol{}",
|
"symbol{}",
|
||||||
@ -346,15 +346,15 @@ fn repr_variants<'a>(
|
|||||||
// that contain all applied modifiers.
|
// that contain all applied modifiers.
|
||||||
applied_modifiers.iter().all(|am| modifiers.contains(am))
|
applied_modifiers.iter().all(|am| modifiers.contains(am))
|
||||||
})
|
})
|
||||||
.map(|(modifiers, c, _)| {
|
.map(|(modifiers, value, _)| {
|
||||||
let trimmed_modifiers =
|
let trimmed_modifiers =
|
||||||
modifiers.into_iter().filter(|&m| !applied_modifiers.contains(m));
|
modifiers.into_iter().filter(|&m| !applied_modifiers.contains(m));
|
||||||
if trimmed_modifiers.clone().all(|m| m.is_empty()) {
|
if trimmed_modifiers.clone().all(|m| m.is_empty()) {
|
||||||
eco_format!("\"{c}\"")
|
value.repr()
|
||||||
} else {
|
} else {
|
||||||
let trimmed_modifiers =
|
let trimmed_modifiers =
|
||||||
trimmed_modifiers.collect::<Vec<_>>().join(".");
|
trimmed_modifiers.collect::<Vec<_>>().join(".");
|
||||||
eco_format!("(\"{}\", \"{}\")", trimmed_modifiers, c)
|
eco_format!("({}, {})", trimmed_modifiers.repr(), value.repr())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user