openclaw - ✅(Solved) Fix Markdown table columns misaligned with CJK characters on Telegram and Discord [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55512Fetched 2026-04-08 01:38:42
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3commented ×1

Markdown tables containing CJK (Chinese/Japanese/Korean) characters are rendered with misaligned columns on both Telegram and Discord channels.

Root Cause

Renders misaligned on Telegram because "类型" (2 chars, 4 display columns) is padded as if it were 2 display columns.

Fix Action

Fixed

PR fix notes

PR #55596: fix(CLI) Markdown table columns misaligned with CJK characters on Telegram and Discord

Description (problem / solution / changelog)

Draft

Closes: #55512

Changed files

  • src/markdown/ir.table-code.test.ts (modified, +64/-0)
  • src/markdown/ir.ts (modified, +113/-2)

Code Example

|          | Framework A              | Framework B         |
|----------|--------------------------|---------------------|
| 类型      | 前端渲染框架                | 后端服务框架           |
| 语言      | TypeScript               | Go                  |
| 部署方式   | 静态托管                   | 容器化部署             |
RAW_BUFFERClick to expand / collapse

Description

Markdown tables containing CJK (Chinese/Japanese/Korean) characters are rendered with misaligned columns on both Telegram and Discord channels.

Problem

  • Telegram: Tables are wrapped in <pre> blocks, but column padding uses String.length instead of display width. CJK characters occupy 2 terminal columns but are counted as 1, causing all subsequent columns to shift left.
  • Discord: Markdown tables are sent as-is with raw pipe (|) syntax. Discord does not support GFM tables natively, so the table renders as plain broken text.

Example

A table like:

|          | Framework A              | Framework B         |
|----------|--------------------------|---------------------|
| 类型      | 前端渲染框架                | 后端服务框架           |
| 语言      | TypeScript               | Go                  |
| 部署方式   | 静态托管                   | 容器化部署             |

Renders misaligned on Telegram because "类型" (2 chars, 4 display columns) is padded as if it were 2 display columns.

On Discord, the table is not rendered at all — raw pipes and dashes are shown.

Expected Behavior

  1. Telegram: Use East Asian Width-aware string width calculation (e.g., string-width npm package or equivalent) when padding table cells in <pre> blocks.
  2. Discord: Convert markdown tables to code blocks with proper monospace alignment (also CJK-aware), since Discord does not support GFM table rendering.

Environment

  • OpenClaw version: 2026.3.24
  • Channels: Telegram, Discord
  • Language: Chinese (zh-CN)

Screenshots

Telegram table rendering with misaligned CJK columns:

The columns after CJK text are shifted left because each CJK character is only counted as width 1 instead of width 2.

References

extent analysis

Fix Plan

To fix the misaligned columns in Telegram and the broken table rendering in Discord, follow these steps:

Telegram Fix

  1. Install the string-width package: npm install string-width
  2. Update the table rendering code to use the string-width package for calculating the display width of strings containing CJK characters.
  3. Replace the existing padding logic with the new width-aware padding.

Example code:

const stringWidth = require('string-width');

// Assuming 'tableData' is a 2D array of table cells
const paddedTable = tableData.map(row => {
  return row.map(cell => {
    const width = stringWidth(cell);
    const padding = ' '.repeat(10 - width); // Adjust padding based on display width
    return cell + padding;
  });
});

Discord Fix

  1. Convert markdown tables to code blocks with proper monospace alignment.
  2. Use the string-width package to calculate the display width of strings containing CJK characters.
  3. Adjust the alignment of the code block based on the calculated display widths.

Example code:

const stringWidth = require('string-width');

// Assuming 'tableData' is a 2D array of table cells
const codeBlock = tableData.map(row => {
  return row.map(cell => {
    const width = stringWidth(cell);
    const padding = ' '.repeat(10 - width); // Adjust padding based on display width
    return cell + padding;
  }).join(' | ');
}).join('\n');

const discordMessage = '```' + codeBlock + '```';

Verification

To verify that the fix worked, test the table rendering on both Telegram and Discord with tables containing CJK characters. The columns should be properly aligned, and the tables should render correctly.

Extra Tips

  • Make sure to handle edge cases, such as tables with varying column widths and rows with different numbers of cells.
  • Consider adding a fallback for older clients that may not support the string-width package or code blocks with monospace alignment.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Markdown table columns misaligned with CJK characters on Telegram and Discord [1 pull requests, 1 comments, 2 participants]