# luk707/rehype-truncate architecture

> Architecture diagram of the GitHub repository luk707/rehype-truncate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luk707/rehype-truncate
- Repository: https://github.com/luk707/rehype-truncate

## Overview

rehype-truncate is a small unified/rehype plugin. A unified processor supplies a HAST tree to the configured transformer, which counts text, respects ignored tags, truncates at the configured limit, and appends an ellipsis; the processor can then stringify the modified tree. The runtime implementation is concentrated in src/index.js; the README documents the surrounding processor workflow and options.

Main entry points: [`src/index.js`](https://github.com/luk707/rehype-truncate/blob/master/src/index.js) (Truncation plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_author(("Processor caller"))
node_unified["Unified processor"]
node_plugin["Truncation plugin<br/>[index.js]"]
node_tree["HAST tree"]
node_stringify["HTML stringifier"]
node_result["HTML output"]

node_author -->|"configures"| node_unified
node_unified -->|"registers"| node_plugin
node_unified -->|"invokes transformer"| node_plugin
node_unified -->|"passes tree"| node_plugin
node_plugin -->|"mutates"| node_tree
node_unified -->|"invokes"| node_stringify
node_stringify -->|"reads"| node_tree
node_stringify -->|"produces"| node_result
node_author -->|"receives"| node_result

click node_plugin "https://github.com/luk707/rehype-truncate/blob/master/src/index.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_author,node_unified,node_tree,node_stringify,node_result toneIndigo
class node_plugin toneTeal
```

## Components

### Other components

- **Processor caller**
- **Unified processor**
- [Truncation plugin](https://github.com/luk707/rehype-truncate/blob/master/src/index.js): `src/index.js`
- **HAST tree**
- **HTML stringifier**
- **HTML output**

## Connections

- Processor caller → Unified processor: configures
- Unified processor → Truncation plugin: registers
- Unified processor → Truncation plugin: invokes transformer
- Unified processor → Truncation plugin: passes tree
- Truncation plugin → HAST tree: mutates
- Unified processor → HTML stringifier: invokes
- HTML stringifier → HAST tree: reads
- HTML stringifier → HTML output: produces
- Processor caller → HTML output: receives
