Skip to content

fix: keep DOT line-break escapes intact in lineage labels - #890

Merged
devdanzin merged 1 commit into
mainfrom
fix/dot-label-newlines
Jul 2, 2026
Merged

devdanzin merged 1 commit into
mainfrom
fix/dot-label-newlines

Conversation

@devdanzin

Copy link
Copy Markdown
Owner

Summary

Rendered lafleur-lineage graphs showed node labels with literal \n on one line (e.g. 444.py\nsniper (3 transformers)\ndepth=6…).

Cause: the label builders insert the DOT centered-newline escape \n, but _escape_dot escaped every backslash (\ → \\), turning \n into \\n; Graphviz renders \\ as a literal backslash.

Fix: _escape_dot now escapes only backslashes that are not part of a DOT line-break escape (\n/\l/\r), preserving intentional line breaks while still escaping stray backslashes and quotes.

Verification

Rendered the exact broken label with dot -Tpng before/after — after the fix it renders as four lines (444.py / sniper (3 transformers) / depth=6 finds=1 / density=0.000 edges=0).

Test plan

  • TestEscapeDot: line-break escapes preserved; stray backslash + quote still escaped; real multi-line label round-trips.
  • Full suite 2177 passed; mypy lafleur clean; ruff clean.

Closes #889

🤖 Generated with Claude Code

_escape_dot escaped every backslash (text.replace("\\", "\\\\")), so the DOT
centered-newline escape `\n` the label builders insert became `\\n`, which
Graphviz renders as a literal backslash-n. Multi-line node/edge labels therefore
collapsed onto a single line.

Escape only backslashes that do not begin a DOT line-break escape (\n/\l/\r), so
intentional line breaks survive while stray backslashes and quotes are still
escaped. Verified by rendering with dot.

Closes #889

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@devdanzin
devdanzin merged commit 30f442e into main Jul 2, 2026
2 checks passed
@devdanzin
devdanzin deleted the fix/dot-label-newlines branch July 2, 2026 17:54
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.

lafleur-lineage: multi-line DOT node labels render on a single line (\n shown literally)

1 participant