-
-
Notifications
You must be signed in to change notification settings - Fork 60
Normalize symbols #332
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
Comments
I'm not sure if I understand the proposal fully, but if a user writes So I guess I'm suggesting the substitution order should be different and unicode substitution should come after determining snakecase so as not to treat unicode subscripts as snakecase. Adding |
(One place where it is common to have multicharacter math variables but not do anything special is in chemical reaction models in biology, which often have multi-character chemical species names.) |
Thank you for your comments! A variable that is both snakecased and has utf8 subscripts sounds pretty cursed, but you're right. I think there will be a Chemical symbols should of course be surrounded in |
True, but if you are using utf subscripts and snakecasing I'm not sure what you can even reasonably expect (and that seems like a pretty exceptional case, usually the two aren't mixed in code I've read). |
#331 highlights an issue in the way we currently deal with variable and function names when it comes to subscripting. Substituting in strings leads to some strange edge cases, and the code is pretty difficult to parse.
I suggest a new model: any symbol (that could represent a variable name or a function name) is only normalized once. It follows something like this schedule:
:a₁ --> :a_1
):abc_x_y --> (:abc, :x, :y)
)snakecase
, sub-symbols arejoin
ed with\_
, otherwise all but the first pair are ("abc_{x\_y}"
)Sub-symbol normalization:
inf
,atan
), get normalized form from dict\mathrm
(configurable?)This leaves an uncertainty in how to sort indexing (
a_1[3]
), and breaks the current behavior oflatexify(:abc) --> "$abc$"
. It will however be more consistent with mathematical notation.The indexing uncertainty is the biggest block to me, we might have to consider using a placeholder struct, more or less saving
:a_b
as a special type of:a[:b]
and delaying the stringification, but that will require a bit of an overhaul.The text was updated successfully, but these errors were encountered: