import { mapMarkdownOutsideProtected } from './asset-markup/markdown-protected.js'; /** * File backfill can produce the same link beside an existing citation. Only * identical labels AND targets separated by horizontal whitespace are redundant: * different locations, prose, paragraphs and table cells must stay intact. * Shared by answer repair and display/history projection; no source inference. */ export function collapseAdjacentDuplicateFileCitations(markdown: string): string { if (!markdown.includes('#mavis-source=file:')) return markdown; return mapMarkdownOutsideProtected(markdown, (text) => { const citationPattern = /(?