Molecules
A molecule is an ordered sequence of atoms and groups, with an optional leading stoichiometric coefficient.
Simple molecules
Section titled “Simple molecules”H_2OCO_2C_6H_12O_6Each atom carries its own subscript. The model is Molecule(nodes: [Atom, Atom, ...]).
Stoichiometric coefficients
Section titled “Stoichiometric coefficients”Leading digits on a molecule are its coefficient:
2H_2O3H_2The Molecule#coefficient field holds the string. The MathML renderer
emits it as an <mn> before the atoms.
Groups
Section titled “Groups”Parenthesised sub-formulas are groups. A group can carry an outer multiplicity.
Ca(OH)_2(NH_4)_2SO_4For Ca(OH)_2:
- Atom
Ca - Group
OHwith multiplicity2, bracket:paren
For (NH_4)_2SO_4:
- Group
NH_4with multiplicity2 - Atoms
S,Owith subscripts4
Bracket variants
Section titled “Bracket variants”AsciiChem supports three bracket kinds:
| Bracket | Open / Close | Use |
|---|---|---|
| Paren | ( ) | Generic grouping (Ca(OH)_2) |
| Square | [ ] | Coordination complexes ([Fe(CN)_6]^4-) |
| Brace | { } | Optional / rare |
The bracket kind is preserved through round-trip — (OH)_2 stays as
(OH)_2, not [OH]_2.
Coordination complexes
Section titled “Coordination complexes”Square brackets wrap coordination complexes. The complex’s charge sits outside the brackets.
[Fe(CN)_6]^4-[Co(NH_3)_6]^3+asciichem gem to see this rendered.
These are parsed as Group(bracket: :square, nodes: [...]) followed
by an Atom with the charge. (In v1, the charge attaches to the last
atom; v2 may promote it to a complex-level attribute.)