mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Extend hint for unknown variables in math (#5038)
This commit is contained in:
parent
320c28844f
commit
f8f95e5c21
@ -137,6 +137,17 @@ fn unknown_variable_math(var: &str, in_global: bool) -> HintedString {
|
||||
res.hint(eco_format!(
|
||||
"`{var}` is not available directly in math, try adding a hash before it: `#{var}`",
|
||||
));
|
||||
} else {
|
||||
res.hint(eco_format!(
|
||||
"if you meant to display multiple letters as is, try adding spaces between each letter: `{}`",
|
||||
var.chars()
|
||||
.flat_map(|c| [' ', c])
|
||||
.skip(1)
|
||||
.collect::<EcoString>()
|
||||
));
|
||||
res.hint(eco_format!(
|
||||
"or if you meant to display this as text, try placing it in quotes: `\"{var}\"`"
|
||||
));
|
||||
}
|
||||
|
||||
res
|
||||
|
@ -81,6 +81,12 @@ $
|
||||
bx(x y) &&quad bx(x (y z)) &quad bx(x y^z) \
|
||||
$
|
||||
|
||||
--- math-call-unknown-var-hint ---
|
||||
// Error: 4-6 unknown variable: ab
|
||||
// Hint: 4-6 if you meant to display multiple letters as is, try adding spaces between each letter: `a b`
|
||||
// Hint: 4-6 or if you meant to display this as text, try placing it in quotes: `"ab"`
|
||||
$ 5ab $
|
||||
|
||||
--- issue-3774-math-call-empty-2d-args ---
|
||||
$ mat(;,) $
|
||||
// Add some whitespace/trivia:
|
||||
|
Loading…
x
Reference in New Issue
Block a user