Skip to content

fix: show a flowchart with non-ASCII text as source instead of mojibake - #25

Merged
hidekingerz merged 1 commit into
mainfrom
claude/mermaid-mbcs
Sep 5, 2026
Merged

fix: show a flowchart with non-ASCII text as source instead of mojibake#25
hidekingerz merged 1 commit into
mainfrom
claude/mermaid-mbcs

Conversation

@hidekingerz

Copy link
Copy Markdown
Owner

Summary

A flowchart with a Japanese node name or edge label (A[開始], -->|はい|) was drawn as mojibake: mermaid-ascii's flowchart renderer (pkg/graph, drawText) places text byte by byte, so each multi-byte character became three broken cells. The sequence renderer measures text with runewidth and is unaffected.

  • internal/ui/mermaid.go: a flowchart / graph block whose source is not all ASCII is left as source, like a block that cannot be drawn. Other diagram types are unchanged.
  • README (both languages) notes the limitation.

Upstream fix (rune- and width-aware placement in pkg/graph) is the real solution; this keeps the output readable until then.

Test plan

  • gofmt -l ., go vet ./..., TMPDIR=/tmp go test -race ./... clean
  • New tests: four non-ASCII flowchart forms (node label, edge label, Latin-1 accent, subgraph title) stay as source; a sequence diagram with Japanese participants and messages still draws

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUYF9hXeZFML1s8r3i2RVX

The flowchart renderer in mermaid-ascii places text byte by byte, so
a Japanese node or edge label came out as three broken cells per
character. Until it handles runes, a flowchart or graph whose source
is not all ASCII stays as source. The sequence renderer measures text
by display width and keeps drawing such labels.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KUYF9hXeZFML1s8r3i2RVX
@hidekingerz
hidekingerz merged commit a34133f into main Sep 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant