Open calculuschild opened 8 months ago
I prefer no hyphens in variables.
Reflinks accept hyphens .. they are human readable labels that appear in the text. They could be all manner of things (e.g. [D&E Mag '94]
or [A+B]
, [Schuster et al, 93]
, [PHB p.23-28]
).
@ericscheid Does it seem reasonable to enforce spaces between math symbols then to allow for math symbols in variable names? Or do you foresee any new edge cases that would cause? Your examples above have both spaces and math symbols, but never spaces between math symbols so those would all be interpreted as valid variable names.
[A+B + PHB p.23-28 / Shuster et al, 93]
would be a valid math expression assuming numbers were assigned to each of those.
Seems a reasonable hack, I don't see any other way with how we've set up [expressions]
.
A variable with a name like this
[ref-01]
contains a math symbol (-
) and so is actually treated as two variable namesref
and01
.However, math is only checked during variable expression when a
$
prefix is attached. This can lead to weird shenanigans:This will assign
url
tolabel-with+math
and even express it as a link. However$[label-with+math]
will not be able to access that variable because math is attempted first. For consistency, checking for math should be done in the variable assignment step as well.Consideration
One thing to consider, is if we want to allow hyphenated var names, which has already come up naturally a few times. We could potentially restrict math to require spaces between operators which may be less confusing to users:
$[hyphenated-name]
vs$[math - expression]
Test Cases
@ericscheid tested a range of other edge cases, some of which show related symptoms: