How luk707/rehype-truncate works
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: index.js Truncation plugin
Components 6
Other components
- Processor caller
- Unified processor
- Truncation plugin
src/index.js - HAST tree
- HTML stringifier
- HTML output
Connections 9
- 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