srs-document/node_modules/@unified-latex/unified-latex-util-argspec/README.md
2025-03-24 15:42:48 +07:00

60 lines
1.4 KiB
Markdown

<!-- DO NOT MODIFY -->
<!-- This file was autogenerated by build-docs.ts -->
<!-- Edit the docstring in index.ts and regenerate -->
<!-- rather than editing this file directly. -->
# unified-latex-util-argspec
## What is this?
Tools to deal with `xparse` argument signatures. (E.g., `"o m"` for optional followed by mandatory
argument).
## When should I use this?
If you are working on the internals of `unified-latex`.
## Install
```bash
npm install @unified-latex/unified-latex-util-argspec
```
This package contains both esm and commonjs exports. To explicitly access the esm export,
import the `.js` file. To explicitly access the commonjs export, import the `.cjs` file.
# Functions
## `parse(str)`
Parse an `xparse` argument specification string to an AST.
This function caches results. Don't mutate the returned AST!
```typescript
function parse(str: String): ArgSpec.Node[];
```
**Parameters**
| Param | Type | Description |
| :---- | :------- | ---------------------- |
| str | `String` | * LaTeX string input |
## `printRaw(node, root)`
Print an `xparse` argument specification AST
to a string.
```typescript
function printRaw(
node: string | ArgSpec.Node | (string | ArgSpec.Node)[],
root: Boolean
): string;
```
**Parameters**
| Param | Type |
| :---- | :-------------------------------- |
| node | <span color='gray'>Omitted</span> |
| root | `Boolean` |