mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-09 13:08:40 +00:00
\newcommand, \renewcommand, \providecommand (#1382)
* \newcommand, \renewcommand, \providecommand * Tests * Add comment * Add symbols to the set of already defined things * Add implicitCommands, catch \hline outside array * Add \relax * Move isDefined to be a method of MacroExpander * Namespace.has * Reword error messages * Add \hdashline given #1407
This commit is contained in:
@@ -56,7 +56,21 @@ export default class Namespace<Value> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of a name.
|
||||
* Detect whether `name` has a definition. Equivalent to
|
||||
* `get(name) != null`.
|
||||
*/
|
||||
has(name: string): boolean {
|
||||
return this.current.hasOwnProperty(name) ||
|
||||
this.builtins.hasOwnProperty(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value of a name, or `undefined` if there is no value.
|
||||
*
|
||||
* Note: Do not use `if (namespace.get(...))` to detect whether a macro
|
||||
* is defined, as the definition may be the empty string which evaluates
|
||||
* to `false` in JavaScript. Use `if (namespace.get(...) != null)` or
|
||||
* `if (namespace.has(...))`.
|
||||
*/
|
||||
get(name: string): ?Value {
|
||||
if (this.current.hasOwnProperty(name)) {
|
||||
|
Reference in New Issue
Block a user