openclaw-md-table-formatter
v0.1.0
Published
Markdown table formatter hook for OpenClaw
Maintainers
Readme
openclaw-md-table-formatter
| | Follow @JungHoonGhae on GitHub for more projects. | | :-----| :----- | | | Follow @lucas_ghae on X for updates. |
Markdown table formatter hook for OpenClaw — format tables in agent tool results automatically.
Disclaimer: This is an independent community hook. It is not affiliated with, endorsed by, or sponsored by OpenClaw. OpenClaw™ is a trademark of its respective owners.
Support
If this hook helps you, consider supporting its maintenance:
The Problem
Markdown tables from AI agents are often messy:
| Name | Age | Role |
|---|---|---|
| Alice | 30 | Engineer |
| Bob | 25 | Designer |Columns don't align. Hard to read. Looks unprofessional in Discord/Telegram.
The Solution
This hook automatically formats markdown tables in agent tool results:
- ✅ Proper column alignment (left, center, right)
- ✅ Handles emojis and unicode characters
- ✅ Preserves markdown inside inline code
- ✅ Works with bold, italic, strikethrough
- ✅ Invalid tables left unchanged with comment
Before
| Name | Age | Role |
|---|---|---|
| Alice | 30 | Engineer |
| Bob | 25 | Designer |After
| Name | Age | Role |
|:------|:---:|:---------|
| Alice | 30 | Engineer |
| Bob | 25 | Designer |Installation
From npm
openclaw hooks install openclaw-md-table-formatterFrom local directory
openclaw hooks install ./path/to/openclaw-md-table-formatterLink for development
openclaw hooks install -l ./path/to/openclaw-md-table-formatterUsage
After installation, enable the hook:
openclaw hooks enable md-table-formatterRestart your gateway:
openclaw gateway --forceThat's it! Tables in tool results will be formatted automatically.
How It Works
This hook intercepts tool_result_persist events, which fire when tool results are about to be saved to the session transcript:
| Step | Action | |------|--------| | 1. Check | Verify tool result contains text content | | 2. Parse | Extract markdown tables from text | | 3. Calculate | Determine column widths (considering markdown, emojis, unicode) | | 4. Format | Apply consistent spacing and alignment | | 5. Return | Save formatted text to transcript |
Features
| Feature | Description |
|---------|-------------|
| Alignment | Left (:---), center (:---:), right (---:) |
| Markdown handling | Strips bold/italic/strike for width calculation |
| Code preservation | Markdown inside `code` stays intact |
| Unicode support | Emojis and CJK characters calculated correctly |
| Error handling | Invalid tables left unchanged with comment |
Troubleshooting
| Problem | Fix |
|---------|-----|
| Hook not found | Run openclaw hooks install openclaw-md-table-formatter |
| Tables not formatting | Run openclaw hooks enable md-table-formatter then restart gateway |
| Invalid table comment | Ensure table has separator row (\|---\|) and same column count |
Requirements
- OpenClaw >= 2026.2.0
Limitations
- Only affects tool results, not user messages or direct agent responses
- Tables must have a valid separator row (
|---|---|) - All rows must have the same number of columns
Development
git clone https://github.com/JungHoonGhae/openclaw-md-table-formatter.git
cd openclaw-md-table-formatter
bun install
bun run buildLinks
- OpenClaw: openclaw.ai - The AI agent gateway
- GitHub: github.com/JungHoonGhae/openclaw-md-table-formatter
- npm Package: npmjs.com/package/openclaw-md-table-formatter
License
MIT - See LICENSE for details.
Contributing
Contributions are welcome! Feel free to submit a Pull Request at github.com/JungHoonGhae/openclaw-md-table-formatter.
Legal Notice
This project is provided "as is" without warranty of any kind. The use of OpenClaw hook API is subject to OpenClaw's terms of service. Users are responsible for complying with all applicable terms and conditions when using this hook.
Related
- opencode-md-table-formatter - Original inspiration for OpenCode
