Repository navigation
Draw any resource id in toMermaid and toDot (0.3.2) - #3
Merged
Merged
Conversation
Both exporters wrote resource ids raw as node ids. Checked against Mermaid 11.17 (parse and mmdc render) and Graphviz dot: Mermaid reads `core:config`, `x/cap` and `-cap` as plain ids, but fails on a space, an `@`, or ids such as `end`, `graph`, `style`, and silently misreads `x:cap(1)` (label "1"), `a:::b` (class b) and `click` (no node). DOT reads `core:config` as node `core`, port `config` (a self-loop core -> core), and fails on `/` and `.`. toMermaid declares each resource once as `n<i>`, numbered in startup order, labelled with its id (`"` and `#` as `#quot;` and `#35;`), and draws edges between those nodes. toDot quotes every id, escaping `\` and `"`. 0.3.2.
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.
Problem
toMermaidandtoDotwrite resource ids raw as node ids (core:config --> core:system,core:config -> core:system;). Ids namespaced likecore:configorx/capare natural in a consumer, and both formats give some characters meaning.Verification
In a scratch project, Mermaid 11.17.2 (
mermaid.mermaidAPI.getDiagramFromTextunder jsdom, and a real render with@mermaid-js/mermaid-clion headless Chrome) and Graphvizdot:core:configcore, portconfig(core:config -> core:systemis a self-loopcore -> core)x/cap,x.cap-cap,x-cap,a"b,a&bmy cache@scope/x,user@xend,graph,style,subgraphx:cap(1)x:caplabelled1a:::bawith classbclickSo
:alone is fine in Mermaid 11, but realistic ids still break it, and DOT is broken for:itself.With the fix, a graph over
core:config,x/cap,my cache\x,end,say "hi" #1and@scope/yrenders every label exactly (mmdc SVG anddot -Tsvg).Fix
toMermaiddeclares each resource once asn<i>, numbered instartupOrder(deterministic), labelled with its id:n0["core:config"]."and#become#quot;and#35;, the entity codes Mermaid decodes. Edges aren0 --> n1. Signature anddirectionunchanged.toDotquotes every id in rank groups and edges, escaping\and".:,/,",#, a space and a backslash.The output changes for every system, plain ids included (every node is now declared with a label).
Alternatives
@,:::, ports), which is exactly what went wrong; one rule for every id is simpler and always correct.core_config): readable, but can collide (a:bvsa_b) and still needs the label for the real name.id["label"]with the raw id quoted is not valid; ids cannot be quoted in Mermaid, so a synthetic id is needed.