// Copyright 2017-2022 The MathJax Consortium// SPDX-License-Identifier: Apache-2.0// This file is a Go translation and modification of MathJax 3.2.2.package mmlimport ()// MactionSelectionNumber applies the numeric coercions used by the source// maction selected getter to supported scalar attribute values.func ( any, bool) float64 {if ! {returnmath.NaN() }switch v := .(type) {casenil:return0casebool:if {return1 }return0caseint:returnfloat64()caseint64:returnfloat64()casefloat64:returncasestring: := strings.TrimFunc(, mactionNumberSpace)if == "" {return0 }iflen() > 2 && [0] == '0' { := 0switch [1] {case'x', 'X': = 16case'b', 'B': = 2case'o', 'O': = 8 }if != 0 {for , := range [2:] { := int( - '0')if >= 'a' && <= 'f' { = int(-'a') + 10 } elseif >= 'A' && <= 'F' { = int(-'A') + 10 }if < 0 || >= {returnmath.NaN() } } , := new(big.Int).SetString([2:], )if ! {returnmath.NaN() } , := .Float64()return } }ifmactionDecimalNumber.MatchString() {// A valid overflowing decimal converts to Infinity. ParseFloat's // range error must not turn it into NaN. , := strconv.ParseFloat(, 64)return } }returnmath.NaN()}// StringNumericLiteral accepts decimal/Infinity and unsigned radix literals;// Go's parser additionally accepts Inf, hex floats and underscores, so validate// the decimal grammar before conversion. Whitespace is the ECMAScript set,// including BOM and excluding Unicode NEL (U+0085).var mactionDecimalNumber = regexp.MustCompile(`^[+-]?(?:Infinity|(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?)$`)func mactionNumberSpace( rune) bool {return == '\t' || == '\n' || == '\v' || == '\f' || == '\r' || == ' ' || == '\u00a0' || == '\u1680' || ( >= '\u2000' && <= '\u200a') || == '\u2028' || == '\u2029' || == '\u202f' || == '\u205f' || == '\u3000' || == '\ufeff'}
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.