asciichemRuby
asciichem-tsasciichem-pygem install asciichemQuick start
Section titled “Quick start”require "asciichem"
formula = AsciiChem.parse("2H_2 + O_2 ->[heat] 2H_2O")formula.to_mathml # presentation MathML (L2 goldens)formula.to_text # canonical AsciiChem text (round-trip)formula.to_structural_svg # 2D structural diagram
# Structures from databases, straight into the same modelAsciiChem.parse_smiles("CC(=O)OC1=CC=CC=C1C(=O)O").to_structural_svgmol = AsciiChem.parse_molfile(File.read("ethanol.mol")) # coordinates preserved
# Resolution: identifiers → substance records with provenancesubstance = AsciiChem::Resolver.resolve(value: "50-78-2", convention: "cas")substance.identifier_value("inchikey") # => "BSYNRYMUTXBXSQ-UHFFFAOYSA-N"
# Canonical wire form (asciichem-model v1)AsciiChem.parse("H_2O").to_model_jsonClaimed levels
Section titled “Claimed levels”Parse / reject · L0 emission · L1 text · L2 MathML · SMILES · molfile · CML · linter — 100% of the shared corpus. See the Implementations matrix for the full table.
What you get here, not elsewhere
Section titled “What you get here, not elsewhere”The reference implementation carries the long tail of features that make the contract concrete:
-
All formatters — MathML, Text (the canonicaliser), HTML, LaTeX, SVG (typographic), StructuralSvg (2D layout), CML via the chemicalml gem, SMILES and molfile writers, and the canonical wire JSON.
-
Opt-in Rust-core engine — the same grammar and transform over Parsanol’s parslet-compat layer, at ~2.4× parse speed; parslet stays the default:
# Gemfile: gem "parsanol", "~> 1.3.16"require "asciichem/engine/parsanol_engine"AsciiChem::Engine.use(:parsanol) -
Citations —
AsciiChem::Citation.to_xml(substance)emits a dataset-type Relaton bibitem per resolved source. CLI:asciichem cite --cas 50-78-2. See Citing substances. -
InChI identity — opt-in engine over the IUPAC
inchi-1binary withIdentityCrossChecklinter. CLI:asciichem identity -i .... See Structures and resolution. -
Beyond formulas — crystals, spectra, computational results, Z-matrices, reaction mechanisms all parse into the semantic model and round-trip.
-
The CLI —
convert,lint,validate,resolve,cite,identity,version. See CLI reference.
Repository
Section titled “Repository”github.com/asciichem/asciichem-ruby — releases flow through trusted publishing (RubyGems OIDC, no stored credentials).