Mermaid scanner: `<pre><span><svg></svg></span></pre>` skip-rule misses author-pre-rendered diagrams in unusual wrappers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- html, javascript, typescript
- Domain
- backend-api-design
Research direction
The skip rule lives in findMermaidBlocks() in apps/api/src/companion/v1.js around line 69, which currently checks for :scope > svg and :scope > div > svg. Read that function and the regression test in apps/api/src/companion/mermaidScanner.test.ts near line 23 first. Done means a pre-rendered <pre class="mermaid"> with an svg under any intermediate element is skipped, the selector change is covered by a test case, and the existing test cases still pass.
Written by the indexing model from the issue text.
Description
Surfaced by: code review on #15 (Mermaid auto-rendering).
findMermaidBlocks() in apps/api/src/companion/v1.js skips a block when it contains :scope > svg or :scope > div > svg. This covers the two common shapes:
- Mermaid-produced post-render:
<pre><svg>…</svg></pre>(mermaid puts the svg directly under the matched element). - Our own post-render:
<pre><div class=\"primer-mermaid\"><svg>…</svg></div></pre>.
Edge case: if an author hand-rolled <pre class=\"mermaid\"><span><svg>…</svg></span></pre> (or some other intermediate element instead of <div>), the skip-rule misses it and Primer would re-render and clobber their existing SVG.
Two options:
- Broaden the selector to
:scope svg(any descendant). Stronger skip, harder to break a pre-rendered diagram, slight risk of skipping a legitimately-empty block that happens to contain an inline icon SVG. - Document as a known edge case in the spec — authors who pre-render are expected to use the canonical shape.
Lean toward option 1 since the risk of a false-positive skip is much smaller than the risk of clobbering an existing diagram.
apps/api/src/companion/v1.js:69
apps/api/src/companion/mermaidScanner.test.ts:23
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 1
- Avg merge
- 13h 38m
- Merged PRs (30d)
- 24
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 0xPolygon/primer
-
Feature: @-mention people and agents in documents and comments; a mention notifies and subscribesOpen
Difficulty 5/5 Over a week Newbie friendliness 18/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 Half a day Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
0xPolygon/primer#185 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement triage
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in 0xPolygon/primer
Similar issues
-
P3
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug L3 level 1 needs-review wocs
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
SatyamPandey-07/WorkSphere#10739 · 1 comment ·
Maintainers usually reply within 1 day
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
assistant-ui/assistant-ui#10946 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
openclaw/openclaw#206303 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day