Repository navigation
fix: use <br/> line breaks in boundary and Lambda labels - #380
Closed
markthomaschurch wants to merge 3 commits into
Closed
markthomaschurch wants to merge 3 commits into
markthomaschurch wants to merge 3 commits into
Conversation
Boundary names are wrapped at 18 characters and joined with "\n", like other element labels. Boundaries use Graphviz HTML-like labels (label = <<i>...</i>>), which do not interpret "\n", so long boundary names were drawn with a literal "\n" in the diagram. Add Element._label_lines() so the wrapping rule is shared, and have Boundary build its HTML label by escaping each line and joining with <br/>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lambda is the other element drawn with a Graphviz HTML-like label (<table><tr><td><b>...</b></td></tr></table>), so long Lambda names had the same literal "\n" problem as boundaries, and "<" or "&" in a Lambda name produced an invalid label. Move _html_label() from Boundary to Element and use it for Lambda. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Pushed one more commit: 48e05ca, "fix: use
The commit moves |
Collaborator
|
Will merge #384 instead. |
izar
added a commit
that referenced
this pull request
Nov 11, 2026
…#384) Fixes #383 > **Depends on #380.** This branch is built on top of #380, because it changes the same label code (`Element._label_lines()`). Until #380 is merged, its two commits also appear here. The change specific to this PR is the last commit, d158420. ## Summary Names containing `"` or `\` broke both diagram types: - **DFD:** `dot` failed with a syntax error, and backslash sequences were read as Graphviz escapes. - **Sequence diagram:** PlantUML turned `\n`/`\t` into a newline and a tab, and a trailing `\` swallowed `@enduml`, so no diagram was produced. ## Changes - `pytm/element.py`: new `dot_escape()` doubles `\` and escapes `"`. `Element._label()` applies it to each wrapped line before joining with `\n`, so pytm's own line breaks still work. This covers every quoted DOT label: elements, dataflows (including merged responses), and the datastore `xlabel` on `master`. - `pytm/tm.py`: new `plantuml_escape()` writes `\` → `<U+005C>` and `"` → `<U+0022>`. It's applied to participant names, message text and notes in `TM.seq()`. - `tests/test_pytmfunc.py`: three regression tests: - DOT escaping. - DOT escaping combined with label wrapping. - PlantUML escaping, including that no raw backslash remains. ## Why Unicode escapes for PlantUML I tested the options with the `plantuml/plantuml:latest` Docker image: | Input in `as "..."` / message | Rendered | |---|---| | `C:\new\tmp\` | `C:` ⏎ `ew` ⇥ `mp`, and a trailing `\` breaks the diagram | | `C:\\new\\tmp\\` | `C:\new` ⇥ `mp\` (inconsistent) | | `C:~\new~\tmp~\` | `C:~` ⏎ `ew~` ⇥ `mp~\` | | `C:<U+005C>new<U+005C>tmp<U+005C>` | `C:\new\tmp\` ✓ | ## Testing - The new tests fail on `master` and pass with this change. - Full suite: `pytest tests` → 266 passed. - Checked by hand: rendered a model with `"` and `\` in actor, server, datastore, dataflow and note text: - DFD with graphviz 2.43: before, `dot` fails with a syntax error; after, every label renders literally. - Sequence diagram with PlantUML (Docker image): before, "No valid @start/@EnD found"; after, every label renders literally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Izar Tarandach <izar@users.noreply.github.com>
izar
approved these changes
Nov 11, 2026
izar
self-requested a review
November 11, 2026 19:02
izar
previously approved these changes
Nov 11, 2026
izar
approved these changes
Nov 11, 2026
izar
approved these changes
Nov 11, 2026
Collaborator
|
Closing as superseded: these changes are already on master via #384. Thanks for the fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #379
Summary
Long names were drawn with a literal
\n(e.g.University of\nMichigan) for the two element types that use Graphviz HTML-like labels, boundaries andLambda, because HTML-like labels need<br/>for line breaks.Changes
pytm/element.py:Element._label_lines()returns the wrapped display name._label()uses it, and its output is unchanged.Element._html_label()HTML-escapes each line (keeping the escaping from fix: escape boundary labels in DFD output #360) and joins the lines with<br/>.pytm/boundary.py:Boundary.dfd()uses_html_label().pytm/asset.py:Lambda.dfd()uses_html_label(). Lambda names were not HTML-escaped before, so a<or&in one also produced an invalid label.tests/test_pytmfunc.py: regression tests for a long boundary name and a long Lambda name that contain<,>and&.Testing
masterand pass with this change.pytest tests→ 263 passed. The existingdfd.dotgolden files are unchanged, because their names are short.dot -Tsvg. Titles now wrap onto separate lines, and no literal\nremains.🤖 Generated with Claude Code