# @unified-latex/unified-latex-util-html-like

> Tools working with HTML-like nodes via 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-html-like
pnpm add @unified-latex/unified-latex-util-html-like
yarn add @unified-latex/unified-latex-util-html-like
bun add @unified-latex/unified-latex-util-html-like
```

## 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-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 29.9 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-html-like
- 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-html-like

## Dependencies (4)

- [@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-match](https://npm.io/package/@unified-latex/unified-latex-util-match.md) ^1.8.4
- [@unified-latex/unified-latex-util-print-raw](https://npm.io/package/@unified-latex/unified-latex-util-print-raw.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-util-html-like/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-html-like

## What is this?

Functions to help with making html-like nodes in a `unified-latex` Abstract Syntax Tree (AST).

For example, `<p>foo</p>` can be stored as `\html-tag:p{foo}` in `unified-latex`. Because `-` and `:`
are special characters, they cannot appear in a macro name, so there is no risk of name conflicts.
These macros are created programmatically, so special characters can be inserted.

## When should I use this?

If you are converting LaTeX to HTML, these functions may be used as an intermediate format.

## Using with `unified-latex-to-hast`

`unified-latex-to-hast` first processes a document into html-like nodes and then
converts the resulting document to HAST/HTML. Any html-like macros that are created
will be transparently converted to HAST/HTML. For example, if you wanted to convert
all `\foo` macros into `<br />` tags, you could first preprocess your unified-latex AST
and replace all occurrences of `\foo` with `htmlLike({ tag: "br" })`. When the AST is converted
to HTML, the html-like macros will be rendered as `<br />` tags.

## Install

```bash
npm install @unified-latex/unified-latex-util-html-like
```

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

## `extractFromHtmlLike(macro)`

Extract the contents/attributes/tag from an html-like macro.

```typescript
function extractFromHtmlLike(macro: Ast.Macro): {
  tag: string;
  attributes: Record<string, string | number | boolean | object>;
  content: Ast.Node[];
};
```

**Parameters**

| Param | Type        |
| :---- | :---------- |
| macro | `Ast.Macro` |

`htmlLike({
    tag,
    content,
    attributes,
})`
---

Make an html-like node storing `content`. The node is a macro and `content` as well
as any attributes can be extracted or further processed. Collisions are avoided with existing
macros because all macros are prefixed with `html-tag:` or `html-attribute:`, which contain
special characters that normal macros cannot have.

```typescript
function htmlLike({
  tag,
  content,
  attributes,
}: {
  tag: string;
  content?: Ast.Node | Ast.Node[];
  attributes?: object;
}): Ast.Macro;
```

**Parameters**

| Param                                                     | Type                              |
| :-------------------------------------------------------- | :-------------------------------- |
| {&#xA;    tag,&#xA;    content,&#xA;    attributes,&#xA;} | <span color='gray'>Omitted</span> |

## `isHtmlLike(node)`

Determine whether the node is an html-like macro.

```typescript
function isHtmlLike(node: any): boolean;
```

**Parameters**

| Param | Type  |
| :---- | :---- |
| node  | `any` |

## `isHtmlLikeAttribute(node)`

Determine whether the node is an html-like macro for an attribute.

```typescript
function isHtmlLikeAttribute(node: any): boolean;
```

**Parameters**

| Param | Type  |
| :---- | :---- |
| node  | `any` |

## `isHtmlLikeTag(node)`

Determine whether the node is an html-like macro for a tag.

```typescript
function isHtmlLikeTag(node: any): boolean;
```

**Parameters**

| Param | Type  |
| :---- | :---- |
| node  | `any` |

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