Show rules for symbols (fixes #1130) (#1175)

This commit is contained in:
sitandr 2023-05-12 13:26:26 +03:00 committed by GitHub
parent fd84d23ade
commit 4b17c3f5c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View File

@ -472,8 +472,10 @@ pub struct ShowableSelector(pub Selector);
impl Cast for ShowableSelector {
fn is(value: &Value) -> bool {
matches!(value, Value::Str(_) | Value::Label(_) | Value::Func(_))
|| value.type_name() == "regular expression"
matches!(
value,
Value::Symbol(_) | Value::Str(_) | Value::Label(_) | Value::Func(_)
) || value.type_name() == "regular expression"
|| value.type_name() == "selector"
}
@ -510,6 +512,7 @@ impl Cast for ShowableSelector {
CastInfo::Type("label"),
CastInfo::Type("string"),
CastInfo::Type("regular expression"),
CastInfo::Type("symbol"),
CastInfo::Type("selector"),
])
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -96,7 +96,7 @@ Hey
= Heading
---
// Error: 7-10 expected function, label, string, regular expression, or selector, found color
// Error: 7-10 expected function, label, string, regular expression, symbol, or selector, found color
#show red: []
---

View File

@ -28,3 +28,8 @@ $text(#red, "time"^2) + sqrt("place")$
// Test different font.
#show math.equation: set text(font: "Fira Math")
$ v := vec(1 + 2, 2 - 4, sqrt(3), arrow(x)) + 1 $
---
// Test using rules for symbols
#show sym.tack: it => $#h(1em) it #h(1em)$
$ a tack b $