// Copyright (c) 2015-2021 Martin Hensel// SPDX-License-Identifier: Apache-2.0
// Package mhchem is a native Go port of mhchemparser 4.1.1, the exact parser// used by MathJax 3.2.2. It expands chemistry and physical-unit notation into// ordinary TeX for a host TeX parser to consume.
package mhchem// Mode selects one of mhchemparser's three source state machines.typeModestringconst (// ModeTeX scans ordinary TeX and expands nested \ce and \pu commands.ModeTeXMode = "tex"// ModeCE parses the argument of \ce.ModeCEMode = "ce"// ModePU parses the argument of \pu.ModePUMode = "pu")// ToTeX returns the exact TeX expansion produced by mhchemparser 4.1.1.func ( string, Mode) (string, error) {switch {caseModeTeX, ModeCE, ModePU:default:return"", errMsg("unknown mode %q (expected tex, ce, or pu)", ) } , := LoadData()if != nil {return"", } := &parserCtx{data: } , := goMachine(, , string())if != nil {return"", }returntexify(, != ModeTeX)}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.