Commit 161c66e
fix(graph): rune-based truncation in dotEscape prevents invalid UTF-8 in DOT output (#105)
* fix(graph2md): writeGraphData uses zero lineCount when startLine absent
writeGraphData computed lineCount only when startLine > 0 && endLine > 0.
For nodes without a startLine (API returns 0), the condition was false and
lineCount remained 0, so the graph visualisation data showed lc=0 even
though the same node's frontmatter correctly computed line_count=endLine
(using effectiveStart=1).
Fix: mirror the effectiveStart=1 defaulting used by all frontmatter writers
— if endLine > 0 but startLine <= 0, treat startLine as 1.
Adds TestGraphDataLineCountMissingStartLine to catch the regression.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(lint): remove extra spaces in parseGraphData struct literal
goimports rejects manually aligned spaces; use single space.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(graph): rune-based truncation in dotEscape to avoid invalid UTF-8
dotEscape used byte indexing (s[len(s)-39:]) to take the last 39
characters of a node name. For names with multi-byte UTF-8 characters
(e.g. accented letters, CJK paths), the byte offset could land in the
middle of a multi-byte sequence, producing invalid UTF-8 in the DOT
output and breaking downstream Graphviz tools.
Fix: convert to []rune and slice by rune index.
Adds TestWriteDOT_LongNameTruncated_MultiByteUTF8 as a regression test
(41 × "é" → the old byte slice cut byte 43, which is the second byte of
U+00E9, producing invalid UTF-8).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 8fa3e47 commit 161c66e
2 files changed
+31
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
0 commit comments