// Copyright 2017-2022 The MathJax Consortium// SPDX-License-Identifier: Apache-2.0package teximport ()// This is ParseUtil.matchDimen's full-token mu branch, not a replacement for// readDimension's existing scanner. In particular, \s here is ECMAScript// whitespace and the decimal digits are ASCII.const muDimensionSpace = `[\t-\r \x{00a0}\x{1680}\x{2000}-\x{200a}\x{2028}\x{2029}\x{202f}\x{205f}\x{3000}\x{feff}]`var muDimensionPattern = regexp.MustCompile(`^` + muDimensionSpace + `*([-+]?(?:[.,][0-9]+|[0-9]+(?:[.,][0-9]*)?))` + muDimensionSpace + `*mu` + muDimensionSpace + `*$`)// normalizeTeXMu applies ParseUtil.muReplace/Em only to a valid full mu value// already extracted by the TeX parser. Other units, invalid values, parser// errors and cursor movement retain their existing behavior. Direct MathML// lengths never pass through this conversion.func normalizeTeXMu( string) string { := muDimensionPattern.FindStringSubmatch()if == nil {return } , := strconv.ParseFloat(strings.Replace([1], ",", ".", 1), 64)if != nil && !math.IsInf(, 0) {return } := / 18ifmath.Abs() < .0006 {return"0em" }// Preserve the primary's exact /\.?0+$/ replacement, including its // behavior on scientific notation returned by toFixed for large numbers.returnstrings.TrimSuffix(strings.TrimRight(jscompat.ToFixed(, 3), "0"), ".") + "em"}
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.