Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math symbols in variable names should not allow variable assignment #3377

Open
calculuschild opened this issue Mar 22, 2024 · 4 comments
Open
Labels
P2 - minor feature or not urgent Minor bugs or less-popular features

Comments

@calculuschild
Copy link
Member

calculuschild commented Mar 22, 2024

A variable with a name like this [ref-01] contains a math symbol (-) and so is actually treated as two variable names ref and 01.

However, math is only checked during variable expression when a $ prefix is attached. This can lead to weird shenanigans:

$[label-with+math]: url  // Assign variable

[label-with+math]     // Output as link

$[label-with+math]   // Fails because math is attempted

This will assign url to label-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:
image

@calculuschild calculuschild added the P2 - minor feature or not urgent Minor bugs or less-popular features label Mar 22, 2024
@dbolack-ab
Copy link
Collaborator

I prefer no hyphens in variables.

@ericscheid
Copy link
Collaborator

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]).

@calculuschild
Copy link
Member Author

calculuschild commented Mar 27, 2024

@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.

@ericscheid
Copy link
Collaborator

Seems a reasonable hack, I don't see any other way with how we've set up [expressions].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 - minor feature or not urgent Minor bugs or less-popular features
Projects
None yet
Development

No branches or pull requests

3 participants