-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fix Chemical formula formatting of formulas such as Na2/3CoO2 and Ni(NO3)2.6H2O #634
Comments
This might be the same issue, but if you put in the chemical formula section (NH4)2(SO4) it renders as NH$_4$SO$_4$ - this is pretty important for molecular stuff. Might be nice to have it also expand it to the empirical formula & molecular mass? |
Yes, this is part of the same issue. I've been meaning to fix this for a while, so will go on and try to come up with something that works nicely across a wider range of cases. For the mean time, the formula is actually just stored as a string in the database, so even though the display is incorrect, your data should be intact (you can see the actual data stored by clicking in the field in the UI) |
I think we should also have a fail-safe, if the entire formula cannot be captured by whatever regexp we conjure up for the formatting, it should just show the formula unformatted. |
good idea I am also am thinking of all the ways we often express formulas, like Li1-xCoO2 if we aren't sure about x. It probably will be hard to properly handle everything people want to do, but we can certainly do a bit better. |
This package might help: https://pypi.org/project/chemformula/#:~:text=Description-,ChemFormula%20is%20a%20Python%20class%20for%20working%20with%20chemical%20formulas,4%E2%8B%85H2O. Doesn't do variable occupancy - I guess it depends what is required. |
Trouble is this part of the code is JavaScript (though I'm sure a similar package exists) -- we could do the parsing on the server side but it would need another round-trip so probably want to avoid it |
No description provided.
The text was updated successfully, but these errors were encountered: