Deduplicate identical mermaid fence blocks by body hash. The caller owns
the seen Set so dedup state persists across artifacts in the same
aggregate.
When a duplicate is found the fence is replaced with a single-line HTML
comment pointing at the earlier occurrence. Non-mermaid fences are left
untouched.
Parameters
md: string
Markdown source that may contain mermaid fences
seen: Set<string>
Shared set of mermaid-body hashes (caller-owned)
Returns {md:string;deduped:number}
{ md, deduped } — cleaned Markdown and count of replacements
Deduplicate identical mermaid fence blocks by body hash. The caller owns the
seenSet so dedup state persists across artifacts in the same aggregate.When a duplicate is found the fence is replaced with a single-line HTML comment pointing at the earlier occurrence. Non-mermaid fences are left untouched.