Project

asciichem

0.0
The project is in a healthy, maintained state
AsciiChem is an ASCII syntax for representing chemical formulae, reactions, electron configurations, and bonds. It parses to a semantic model and renders to MathML, HTML, LaTeX, and SVG. Math embedding uses Plurimath.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.2.1
~> 1.0
~> 1.16
~> 2.0
~> 0.8
~> 1.3
 Project Readme

AsciiChem

AsciiChem is an ASCII syntax for representing chemistry: atoms, molecules, bonds, reactions, electron configurations, and embedded mathematics. It parses to a semantic model and renders to MathML, HTML, LaTeX, and SVG.

Why

AsciiMath is insufficient for chemistry:

  • Prefix superscripts/subscripts have no atom to bind to — AsciiMath forces a phantom {} carrier (e.g. {}^14C), which is semantically wrong: the isotope belongs to the atom, not to an empty element.

  • No native syntax for stoichiometric coefficients, reaction arrows, conditions, or spectator ions.

  • No representation for electron configuration, term symbols, or bonds.

  • No structural diagrams.

AsciiChem closes these gaps.

Installation

Add to your Gemfile:

gem "asciichem"

Or install directly:

$ gem install asciichem

Usage

require "asciichem"

formula = AsciiChem.parse("H_2O")
formula.to_mathml  # => "<math>...</math>"
formula.to_text    # => "H_2O"  (round trip)

Design

See ARCHITECTURE.adoc and the specification at https://www.asciichem.org.

License

BSD-2-Clause. See LICENSE.