# @unified-latex/unified-latex-util-arguments

> Tools for manipulating unified-latex ASTs

Latest version **1.8.4** (published 2026-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @unified-latex/unified-latex-util-arguments
pnpm add @unified-latex/unified-latex-util-arguments
yarn add @unified-latex/unified-latex-util-arguments
bun add @unified-latex/unified-latex-util-arguments
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.8.4 |
| Published | 2026-04-03 |
| First published | 2022-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 91.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 127 |
| Author | Jason Siefken |
| Maintainers | siefkenj |
| Keywords | pegjs, latex, parser, prettier, unified-latex, unified |

## Links

- npm: https://www.npmjs.com/package/@unified-latex/unified-latex-util-arguments
- Repository: https://github.com/siefkenj/unified-latex
- Homepage: https://github.com/siefkenj/unified-latex#readme
- Issues: https://github.com/siefkenj/unified-latex/issues
- npm.io page: https://npm.io/package/@unified-latex/unified-latex-util-arguments

## Dependencies (8)

- [unified](https://npm.io/package/unified.md) ^10.1.2
- [@unified-latex/unified-latex-types](https://npm.io/package/@unified-latex/unified-latex-types.md) ^1.8.4
- [@unified-latex/unified-latex-builder](https://npm.io/package/@unified-latex/unified-latex-builder.md) ^1.8.4
- [@unified-latex/unified-latex-util-scan](https://npm.io/package/@unified-latex/unified-latex-util-scan.md) ^1.8.4
- [@unified-latex/unified-latex-util-match](https://npm.io/package/@unified-latex/unified-latex-util-match.md) ^1.8.4
- [@unified-latex/unified-latex-util-visit](https://npm.io/package/@unified-latex/unified-latex-util-visit.md) ^1.8.4
- [@unified-latex/unified-latex-util-argspec](https://npm.io/package/@unified-latex/unified-latex-util-argspec.md) ^1.8.4
- [@unified-latex/unified-latex-util-render-info](https://npm.io/package/@unified-latex/unified-latex-util-render-info.md) ^1.8.4

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.8.4 (latest) — 2026-04-03
- 1.8.3 — 2025-06-16
- 1.8.2 — 2025-02-09
- 1.8.1 — 2024-10-21
- 1.8.0 — 2024-08-22
- 1.7.1 — 2024-03-19
- 1.7.0 — 2024-02-25
- 1.6.1 — 2024-02-18
- 1.6.0 — 2024-01-17
- 1.4.2 — 2023-09-30
- 1.4.0 — 2023-06-20
- 1.3.2 — 2023-04-26
- 1.3.1 — 2023-03-05
- 1.3.0 — 2023-02-06
- 1.2.2 — 2022-12-15
- … 11 more at https://npm.io/package/@unified-latex/unified-latex-util-arguments/versions

## README

<!-- 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-arguments

## What is this?

Functions to help modify and attach arguments to macros in a `unified-latex` Abstract Syntax Tree (AST).

By default, TeX doesn't actually have a concept of macro "arguments". Instead, TeX searches the
tokens after a macro and processes them according to the macro's rules. However, LaTeX attempts
to make macros look like functions that accept arguments. To attach the "arguments" to a macro
node, the `unified-latex` AST needs to be reparsed and manipulated.

## When should I use this?

If you have custom macros that you want arguments attached to.

If you know ahead of time which macros need arguments attached to them, use `unified-latex-util-parse`
and pass in the appropriate macro info instead.

## Install

```bash
npm install @unified-latex/unified-latex-util-arguments
```

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.

# Plugins

## `unifiedLatexAttachMacroArguments`

Unified plugin to attach macro arguments to the macros specified via the `macros`
option.

### Usage

`unified().use(unifiedLatexAttachMacroArguments[, options])`

#### options

```typescript
{ macros: MacroInfoRecord; }
```

### Type

`Plugin<{ macros: MacroInfoRecord; }[], Ast.Root, Ast.Root>`

```typescript
function unifiedLatexAttachMacroArguments(options: {
  macros: MacroInfoRecord;
}): (tree: Ast.Root) => void;
```

# Functions

## `getArgsContent(node)`

Returns the content of `args` for a macro or environment as an array. If an argument
was omitted (e.g., because it was an optional arg that wasn't included), then `null` is returned.

```typescript
function getArgsContent(node: Ast.Macro | Ast.Environment): Ast.Node[][];
```

**Parameters**

| Param | Type                           |
| :---- | :----------------------------- |
| node  | `Ast.Macro \| Ast.Environment` |

## `getNamedArgsContent(node, namedArgumentsFallback)`

Returns the content of `args` for a macro or environment as an object whose keys are the "names"
of each argument. These names of the arguments must be specified in the `_renderInfo` prop. If `_renderInfo`
does not contain a `namedArguments` array, then an empty object will be returned.

```typescript
function getNamedArgsContent(
  node: Ast.Macro | Ast.Environment,
  namedArgumentsFallback: readonly string[]
): Record<string, Ast.Node[]>;
```

**Parameters**

| Param                  | Type                           |
| :--------------------- | :----------------------------- |
| node                   | `Ast.Macro \| Ast.Environment` |
| namedArgumentsFallback | `readonly string[]`            |

## `gobbleSingleArgument(nodes, argSpec, startPos)`

Gobbles an argument of whose type is specified
by `argSpec` starting at the position `startPos`.
If an argument couldn't be found, `argument` will be `null`.

```typescript
function gobbleSingleArgument(
  nodes: Ast.Node[],
  argSpec: ArgSpec.Node,
  startPos: Number
): { argument: Ast.Argument | null; nodesRemoved: number };
```

**Parameters**

| Param    | Type           |
| :------- | :------------- |
| nodes    | `Ast.Node[]`   |
| argSpec  | `ArgSpec.Node` |
| startPos | `Number`       |

---
_Source: https://npm.io/package/@unified-latex/unified-latex-util-arguments · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
