KnowledgeBaseclass#
Immutable knowledge shared by parsers, engines and documents.
It defines the known commands, environments, characters, and delimiters that parsing, transforms, and Document construction and edits check against. Share one instance across a Parser, TransformEngine, and their documents. Enumerations are sorted by name and returned as copies.
const knowledgeBase = new KnowledgeBase({ packages: ['ams'] });
const { document } = new Parser({ knowledgeBase }).parse(String.raw`\frac{a}{b}`);KnowledgeBase#
KnowledgeBase(options: KnowledgeBaseOptions | undefined)Build the knowledge base once. Throws TexformConfigError for an invalid package name or item.
| Parameter | Type |
|---|---|
options | Knowledge |
free#
free(): void[Symbol.dispose]#
[Symbol.dispose](): voidisSame#
isSame(other: KnowledgeBase): booleanWhether other is the same instance; equality is identity, not recipe.
| Parameter | Type |
|---|---|
other | Knowledge |
booleancommands#
commands(mode: RuntimeContentMode): CommandInfo[]| Parameter | Type |
|---|---|
mode | Runtime |
CommandInfo[]environments#
environments(mode: RuntimeContentMode): EnvInfo[]| Parameter | Type |
|---|---|
mode | Runtime |
EnvInfo[]characters#
characters(mode: RuntimeContentMode): CharacterInfo[]| Parameter | Type |
|---|---|
mode | Runtime |
CharacterInfo[]lookupCharacter#
lookupCharacter( name: string, mode: RuntimeContentMode,): CharacterInfo | null| Parameter | Type |
|---|---|
name | string |
mode | Runtime |
CharacterInfo | nulllookupCommand#
lookupCommand( name: string, mode: RuntimeContentMode,): CommandInfo | null| Parameter | Type |
|---|---|
name | string |
mode | Runtime |
CommandInfo | nulllookupEnv#
lookupEnv(name: string, mode: RuntimeContentMode): EnvInfo | null| Parameter | Type |
|---|---|
name | string |
mode | Runtime |
EnvInfo | nulllookupExplicitCommand#
lookupExplicitCommand( name: string, mode: RuntimeContentMode,): CommandInfo | null| Parameter | Type |
|---|---|
name | string |
mode | Runtime |
CommandInfo | nullKnowledgeBaseOptionsinterface#
Construction options for an immutable KnowledgeBase.
Omit packages to load the default runtime packages, not every package in
the catalog. Use listPackages() to see the available names; an unknown name
throws TexformConfigError.
| Field | Type | Description |
|---|---|---|
packages | string[ | Package names to load; omit to load the default runtime packages. |
items | Context | Custom command/environment/delimiter-control knowledge to inject. |
removeCommands | string[ | Command names to drop from the loaded knowledge. |
removeEnvironments | string[ | Environment names to drop from the loaded knowledge. |
removeDelimiterControls | string[ | Delimiter-control names to drop from the loaded knowledge. |
DelimiterInfointerface#
| Field | Type |
|---|---|
name | string |
isControlSequence | boolean |
allowedMode | string |
unicodeValue | string |
attributes | { mathvariant: string | |
package | string |
ConstructionOptionsinterface#
Options for the create* methods. mode is the context mode of the detached subtree. It defaults to text for createInlineMath, math for
createDelimitedGroup, createScripted, createPrime, and createInfix, the group's own
mode for createGroup, and the document root mode otherwise.
| Field | Type |
|---|---|
mode | Runtime |