tidy icon indicating copy to clipboard operation
tidy copied to clipboard

Default not shown when it is given by a variable

Open nwin opened this issue 1 month ago • 4 comments

When the default value is a variable tidy only displays the variable name without any way to display its content.

Here only default-foldmarks is shown: Image

Here the default value is shown: Image

nwin avatar Nov 11 '25 16:11 nwin

Hi @nwin , This is the intended behavior. What is shown is just the code placed as the default and it is not (and technically cannot really be) resolved.

You can either write out the value or document the variable.

Mc-Zen avatar Nov 11 '25 17:11 Mc-Zen

But the variable documentation also omits the value as you see in the bottom of the screenshot.

nwin avatar Nov 11 '25 18:11 nwin

Variables currently do not have the notion of a "default" (in fact packages expose no variables but rather constants because they cannot be changed from outside the package but anyway). However, this seems like a useful addition to Tidy!

Mc-Zen avatar Nov 17 '25 09:11 Mc-Zen

Actually, I might have to remedy that because it could prove to be too hard too parse the value of the variable. For simple variable definitions like

#let pi = 3.14159

that's easy. But variables could potentially be extremely complex, dynamically resolved dictionaries and it's far beyond the scope of Tidy to parse this. And a solution that only detects simple things feels very half-baked to me.

I think all in all it would be better to just document the value in the variable description. This also makes sense because often variables will be expressions that Typst evaluates to a value.

The only possible solution I can think of might be evaluating the file and getting the evaluated value for a variable.

Mc-Zen avatar Nov 17 '25 18:11 Mc-Zen