// Copyright (c) 2009-2022 The MathJax Consortium // SPDX-License-Identifier: Apache-2.0 // Source: BaseMethods.BeginEnd and ParseUtil.checkMaxMacros.
package tex import func ( *parser) ( string) (string, error) { , , := .readArgument(, false) if != nil { return "", } if strings.Contains(, `\`) { return "", texError("InvalidEnv", "Invalid environment name '%s'", ) } return , nil } func ( *parser) () error { .state.macroCount++ if .state.macroCount > maxMacros { return texError("MaxMacroSub2", "MathJax maximum substitution count exceeded; is there a recursive latex environment?") } return nil } // BeginEnd returns an EndItem before checkMaxMacros only for a registered // environment with a falsy first macro argument. Truthy entries (including // empheq) and user-defined ends take the charged environment-dispatch path. // Retained maps keep this independent of Go's supported environment handlers. func ( *parser) ( string) bool { , := .sourceEndDefinition() return } func ( *parser) ( string) (bool, bool) { if , := .state.environments[]; { return true, false } for , := range mjSourceMaps { if .Kind != mjSourceEnvironmentMap || (!.state.augmentedPackages && strings.Contains(.Source, "/empheq/")) { continue } for , := range .Entries { if .Name == { , := .Value.(mjSourceList) if len() < 2 { return true, true } , := [1].(mjSourceUndefined) return true, || !limitsTruthy([1]) } } } return false, false }