# @unified-latex/unified-latex-builder

> Tools for constructing 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-builder
pnpm add @unified-latex/unified-latex-builder
yarn add @unified-latex/unified-latex-builder
bun add @unified-latex/unified-latex-builder
```

## 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-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 39.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-builder
- 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-builder

## Dependencies (1)

- [@unified-latex/unified-latex-types](https://npm.io/package/@unified-latex/unified-latex-types.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.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.1 — 2023-03-05
- 1.3.0 — 2023-02-06
- 1.2.2 — 2022-12-15
- 1.2.1 — 2022-11-23
- 1.2.0 — 2022-11-13
- 1.1.0 — 2022-11-06
- … 8 more at https://npm.io/package/@unified-latex/unified-latex-builder/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-builder

## What is this?

Functions to help build a `unified-latex` Abstract Syntax Tree (AST)
with [hyperscript](https://github.com/dominictarr/hyperscript)-like syntax.

## When should I use this?

If you want to programmatically create `Ast.Node` nodes.

## Install

```bash
npm install @unified-latex/unified-latex-builder
```

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

## `arg(args, special)`

Create an Argument. `special.braces` can optionally specify
the signature of the open/close marks that each argument uses. For example

```
arg("a", { braces: "[]" });
```

will result in arguments `[a]`. Valid braces are `*`, `[`, `{`, `<`, and `(`.

`null` may be passed as the value of an empty optional argument. If `null` is passed,
the `openBrace` and `closeBrace` of the argument will be set to empty strings and the
contents will be set to an empty array. For example,

```
args([null, "b"], { braces: "[]{}" });
```

will produce the same structure as if the the first "optional argument" were omitted in regular parsing.

```typescript
function arg(args: CoercibleArgument | Ast.Node[], special: ArgumentSpecialOptions): Ast.Argument
```

**Parameters**

| Param   | Type                              |
| :------ | :-------------------------------- |
| args    | <span color='gray'>Omitted</span> |
| special | `ArgumentSpecialOptions`          |

## `args(args, special)`

Create an Argument list. `special.braces` can optionally specify
the signature of the open/close marks that each argument uses. For example

```
args(["a", "b"], { braces: "[]{}" });
```

will result in arguments `[a]{b}`. Valid braces are `*`, `[`, `{`, `(`, and `<`.

`null` may be passed as the value of an empty optional argument. If `null` is passed,
the `openBrace` and `closeBrace` of the argument will be set to empty strings and the
contents will be set to an empty array. For example,

```
args([null, "b"], { braces: "[]{}" });
```

will produce the same structure as if the the first "optional argument" were omitted in regular parsing.

```typescript
function args(args: CoercibleArgument | CoercibleArgument[], special: ArgumentsSpecialOptions): Ast.Argument[]
```

**Parameters**

| Param   | Type                              |
| :------ | :-------------------------------- |
| args    | <span color='gray'>Omitted</span> |
| special | `ArgumentsSpecialOptions`         |

## `env(name, body, envArgs, special)`

Create an Environment node.

```typescript
function env(name: String, body: CoercibleNode | CoercibleNode[], envArgs: CoercibleArgument | CoercibleArgument[], special: {}): Ast.Environment
```

**Parameters**

| Param   | Type                              |
| :------ | :-------------------------------- |
| name    | `String`                          |
| body    | <span color='gray'>Omitted</span> |
| envArgs | <span color='gray'>Omitted</span> |
| special | `{}`                              |

## `m(name, marcoArgs, special)`

Create a Macro with the given `name`. The macro
may be followed by any number of arguments.

```typescript
function m(name: String, marcoArgs: CoercibleArgument | CoercibleArgument[], special: MacroSpecialOptions): Ast.Macro
```

**Parameters**

| Param     | Type                              |
| :-------- | :-------------------------------- |
| name      | `String`                          |
| marcoArgs | <span color='gray'>Omitted</span> |
| special   | `MacroSpecialOptions`             |

## `s(value)`

Create a String node from `value`

```typescript
function s(value: string | Ast.String): Ast.String
```

**Parameters**

| Param | Type                   |
| :---- | :--------------------- |
| value | `string \| Ast.String` |

# Constants

| Name | Type             | Description      |
| :--- | :--------------- | :--------------- |
| `SP` | `Ast.Whitespace` | Whitespace node. |

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