New plugin - molmass 0.1.0 - calculate molar mass of a chemical compound

Hello,

I wrote a small plugin to help me with a frequent task for chemistry students: calculating the molar mass of a compound, given its molecular formula.

See below a screenshot of the functionality it provides:

image

You can download it from https://jerojasro.github.io/tw-molmass/ and check its docs, how to use it, etc. over there.

12 Likes

Thanks for Sharing, If you have not seen it already, check out Periodic Table and the discussion

1 Like

Hi @jerojasro,
I just played with molmas. It is simple and powerful. I like it!
Just a small question: the molmass is a JS macro, why did you not write it using WikiText? I am just curious to know.

By the way, many thanks for sharing this nice piece of work. While it is your first plugin, it is written with good logic, well documented and is easy to use for newbies.

I highly recommend having a look at Periodic Table (crosseye.github.io). It is one the best in the field.

Please add it to links

The more active / up-to-date link is this one: Chemistry — periodic table and related tools

1 Like

Hello,

Because formulas like (CH3)2SO4 require recursion to process them, since you have a subformula inside the parentheses; by writing the macro using javascript I was able to handle that situation (subformulas with arbitrary levels of nesting) without too much effort.

Also, because javascript allows me to perform proper error handling, and deciding how to show (or not show, or simplify) the errors that might appear.

1 Like

This is great!

I wonder if you would object if I eventually folded it – with proper attribution, of course – into my Chemistry wiki when I get back to working on it (soon I hope, although many things, including a recent vacation, are slowing that down.)

I have written some recursive wikitext macros. I don’t share the objections some here have to reaching for JS when not absolutely necessary, but I am curious whether this could be rewritten in readable wikitext. It won’t be for a while, but I may take a stab at it.

not at all; please go ahead; if you require a different license so it matches the licensing of your project, let me know.

indeed, my main concern here is readability. If that’s possible/you get around to it, I’d be most interested :grinning:

Thank you very much. I haven’t really thought about license yet. A coder, I’m used to MIT-style licenses, and only occasionally GPL-style ones. This is probably more likely something that would require CC BY (or perhaps CC BY-SA) licensing. At some point I guess I need to think about it.

If and when I get to it, I’ll let you know. To my JS-trained eyes, almost always JS solutions are more readable than wikitext ones. But I’m getting more accustomed to WT, and perhaps that will change.

I thought it would be worth adding a link here to a question I asked regarding how to pass a value from a field to this macro… answered in typical style by @EricShulman.