From 530412529079dc8cd9c37c7d66120785474e6cc6 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Mon, 6 Jan 2025 08:45:10 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Label=20duplication=20w?= =?UTF-8?q?arning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/lucky-squids-hug.md | 5 +++++ packages/myst-common/src/utils.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/lucky-squids-hug.md diff --git a/.changeset/lucky-squids-hug.md b/.changeset/lucky-squids-hug.md new file mode 100644 index 000000000..0f5c57940 --- /dev/null +++ b/.changeset/lucky-squids-hug.md @@ -0,0 +1,5 @@ +--- +"myst-common": patch +--- + +Improve label duplication warning diff --git a/packages/myst-common/src/utils.ts b/packages/myst-common/src/utils.ts index 10b9d400f..bf7098228 100644 --- a/packages/myst-common/src/utils.ts +++ b/packages/myst-common/src/utils.ts @@ -90,11 +90,16 @@ export function createHtmlId(identifier?: string): string | undefined { */ export function transferTargetAttrs(sourceNode: GenericNode, destNode: GenericNode, vfile?: VFile) { if (sourceNode.label) { - if (destNode.label && vfile) { + if (destNode.label && vfile && destNode.label !== sourceNode.label) { fileWarn(vfile, `label "${destNode.label}" replaced with "${sourceNode.label}"`, { node: destNode, }); } + if (destNode.label && vfile && destNode.label === sourceNode.label) { + fileWarn(vfile, `duplicate label "${destNode.label}" replacement`, { + node: destNode, + }); + } destNode.label = sourceNode.label; delete sourceNode.label; }