Merge Two Notes and Their Footnotes Point to the Wrong Source
When you merge two daily notes into a weekly note — by concatenating them, pasting a paragraph, or piping them through a renderer — and both notes use [^1] as a footnote label, the merged document cites one source for both claims. No warning. No visible error. Nine renderer configurations confirmed this in a measured test run on 2026-11-14.1
The failure is not a bug in any single tool. It is a consequence of a rule the CommonMark specification states plainly, that most renderers implement silently, and that almost no merge workflow surfaces to the writer. Understanding the rule takes two minutes. The fixes take less.
The problem in concrete terms
A footnote label like [^1] is a document-scoped key. When you merge two notes, the document boundary expands to contain both. Each key can have only one winning definition. The second definition disappears, and the reference it was supposed to describe now points at the first note's source — silently, in 8 of 9 engine configurations tested.1
Here is the scenario in minimal form. Monday's note says:
Claim A.[^1]
[^1]: Source A.
Tuesday's note says:
Claim B.[^1]
[^1]: Source B.
After cat monday.md tuesday.md or a simple paste, the merged document has two [^1] references and two [^1] definitions. Every renderer must choose. The spec says the first definition wins.2 Seven of nine configurations follow that rule. Two follow a different one. None except pandoc's own markdown reader print a warning.3
The result is not a missing footnote. MNMNOTE's post on footnote syntax puts it precisely: "the footnote travels with the sentence it belongs to."4 That is true inside one file. When a sentence moves into another file — or another file moves into it — the sentence and its definition are no longer guaranteed to arrive together.
Why only one definition can win
The CommonMark specification is unambiguous: "If there are several matching definitions, the first one takes precedence."2 That sentence comes from §4.7, the section on link reference definitions. The rule applies to reference links ([1]) and, by extension, to footnote labels ([^1]) in every implementation that follows the same design.
Section §6.3 of the same spec goes one step further: "If there are multiple matching reference link definitions, the one that comes first in the document is used. (It is desirable in such cases to emit a warning.)"3
That parenthetical — "it is desirable" — is not a requirement. It is a recommendation. Only one of the nine configurations tested acted on it.
The spec also normalises labels before comparing them: "matching of labels is case-insensitive" with a Unicode case fold.3 [Report] and [report] are the same key. In the test, case-variant labels collided in all nine configurations, following the same 7-first / 2-last split as identical labels.1
Python-Markdown's collision behaviour comes from its implementation, not its documentation. The parser stores each reference in a plain dictionary keyed by the lower-cased label — self.parser.md.references[id] = (link, title) — so a second definition overwrites the first.5 The last definition wins.
pandoc's markdown reader follows a different rule — it also uses the last definition, then emits a warning. Both are valid choices for a parser not bound by CommonMark. Neither is wrong. Neither warns by default except pandoc.
Nine renderers, one test
The test ran nine engine configurations against a merged pair of notes — each containing a reference link and a footnote with the same label [1] / [^1], pointing at different sources. The engines were pinned to released versions and run from fresh installs; full inputs, scripts, outputs, and SHA256 checksums are in materials/receipts/.1 For which engines support footnotes at all, see the Markdown edge-cases post.
Table A — both notes merged, both using label [^1].
| Engine | Reference links go to | Footnotes show | Warns? |
|---|---|---|---|
| markdown-it 15.0.3 + footnote 4.0.0 | A | one footnote: Source B | no |
| commonmark.js 0.31.2 | A | no footnote support: both definitions printed as text | no |
| marked 18.2.0 | A | no footnote support: both definitions printed as text | no |
| micromark 4.0.3 + gfm | A | one footnote: Source A | no |
| Python-Markdown 3.11.3 + footnotes | B | one footnote: Source B | no |
| mistune 3.4.0 + footnotes | A | one footnote: Source A | no |
pandoc 3.13 -f markdown | B | two footnotes, both Source B | yes |
pandoc 3.13 -f gfm | A | two footnotes, both Source A | no |
GitHub POST /markdown | A | one footnote: Source A | no |
Seven configurations follow first-wins. Python-Markdown and pandoc -f markdown follow last-wins.5 Only pandoc -f markdown warns, printing [WARNING] Duplicate link reference '[1]' and Duplicate note reference '1'.6
The pandoc -f markdown row deserves a second look. It renders two numbered footnotes — both with the same body text. The document looks fully cited. Both claims carry a superscript. Both have a matching entry in the footnote list at the bottom. The only sign that something is wrong is a warning on stderr that is easy to miss and trivial to silence.
The 356,449-view Stack Overflow thread on merging Markdown files7 has a 28-score answer recommending pandoc -s $(cat includes.txt) --quiet -f markdown -t html5. Adding --quiet prints zero warnings on the colliding merge.1 The warning disappears; the wrong source remains.
Three fixes, in order
There are three reliable fixes, in increasing complexity: rename every label to be unique before merging, use pandoc's --file-scope flag to merge collision-safely, or for the paste case, carry each definition with the paragraph it belongs to. The right choice depends on whether you control both notes and whether you rely on cross-file link definitions.
Fix 1 — unique labels (always safe).
Rename every label before it has a chance to collide. Date-based labels work well:
Claim A.[^2026-11-10-a]
[^2026-11-10-a]: Source A.
Claim B.[^2026-11-11-a]
[^2026-11-11-a]: Source B.
After merging, both definitions survive in all nine configurations tested.1
One caveat: running a pandoc Markdown round-trip on uniquely-labelled notes renumbers them back. pandoc -f markdown -t markdown rewrote [^2026-11-10-a] to [^1] in the test. Using --reference-location=block did the same. If you normalise notes with pandoc before merging, you trade the collision-proof labels for collision-prone ones. Skip the round-trip, or run it only on the final merged document, never on the individual notes.
The Python-Markdown documentation names the design intent: "A footnote name is a string that uniquely identifies a footnote within the document."8 "Within the document" is load-bearing. The merge makes two documents one.
Fix 2 — merge with pandoc --file-scope.
pandoc's MANUAL describes the flag precisely: "Parse each file individually before combining for multifile documents. This will allow footnotes in different files with the same identifiers to work as expected. If this option is set, footnotes and links will not work across files."9
pandoc --file-scope -f markdown -t markdown a.md b.md -o merged.md
The output renames the conflicting labels automatically — [^1] from each file becomes [^1] and [^2] in the merged document, each pointing at its correct source. Without the flag, the same command produces Source B twice and prints two warnings.1
The cost is in that same MANUAL sentence. The top-voted Stack Overflow answer on merging Markdown files7 — score 316, still the reference answer after fifteen years — relies on cross-file link definitions: "Since pandoc will merge all the files prior to doing the translation, you can include your links in the last file."10 If you keep a shared links.md file, --file-scope breaks that pattern. Use unique labels instead.
Fix 3 — paste case: carry the definition with the paragraph.
If you are pasting a single paragraph from one note into another, pandoc -t markdown --reference-links --reference-location=block places each definition immediately below the paragraph it belongs to. The sentence and its citation travel together.9
A paragraph pasted without its definition renders as literal brackets in all nine configurations — [the report][1] and [^1] appear verbatim, unrendered.1 The paste case is obvious to the reader, which makes it easier to catch than the silent collision. Carry the definition or use inline links.
Detecting a collision before it matters
Both detectors run on the source file, before any renderer sees it. The pandoc detector is precise but requires the markdown reader specifically. The grep detector runs anywhere, with no dependencies.
Detector 1 — pandoc.
pandoc -f markdown -t html --fail-if-warnings -o /dev/null note.md
This exits with status 3 on a collision and status 0 on a clean file.9 Two constraints matter. First, use -f markdown, not -f gfm. The GFM reader does not emit duplicate-reference warnings, so -f gfm exits 0 on a collision.1 Second, do not add --quiet — that flag suppresses all warnings and returns exit 0 regardless.1
The scope of this detector is narrower than it looks. As documented in the Markdown table-cell post, --fail-if-warnings does not catch deleted HTML inside table cells — unlike footnote collisions, which the markdown reader flags reliably.11 The flag catches what the reader warns about, and the GFM reader warns about almost nothing.
Detector 2 — grep (no pandoc needed).
grep -oE '^ {0,3}\[[^]]+\]:' note.md \
| sed 's/^ *//' \
| tr '[:upper:]' '[:lower:]' \
| sort \
| uniq -d
This prints any duplicated definition lines — [1]:, [^1]:, [report]: — for a merged file with collisions, and nothing for a clean file. It performs an ASCII case fold, which approximates the spec's Unicode case fold for labels that stay in the ASCII range. For multilingual labels, the pandoc detector is more precise.
Frequently Asked Questions
What happens if two Markdown footnotes have the same label?
Every renderer keeps one definition and drops the other. Seven of nine configurations tested use the first definition and ignore the second. Two — Python-Markdown and pandoc's markdown reader — use the last. Only pandoc prints a warning. The wrong source appears in the rendered output with no visible marker that anything went wrong.1
Which footnote definition wins when labels collide?
It depends on the renderer. CommonMark specifies first-wins.3 Most renderers follow that rule. Python-Markdown stores references in a dictionary that overwrites on collision, so the last definition wins.5 pandoc's markdown reader also uses the last definition and emits a warning. pandoc's gfm reader uses the first definition silently.1
How do I merge Markdown files without breaking footnotes?
Two options. First: use unique labels before merging — date-based ([^2026-11-10-a]) or citekey-style labels survive any merge in all engines. Second: merge with pandoc --file-scope -f markdown -t markdown, which renames colliding labels automatically.9 If you rely on cross-file link definitions in a shared file, --file-scope breaks that pattern — use unique labels instead.
Does pandoc warn about duplicate footnote labels?
Yes, but only with the -f markdown reader. The warning text is Duplicate note reference '<label>'.6 The -f gfm reader does not warn on the same collision.1 Adding --quiet silences the warning regardless of reader. A community answer on the most-viewed Markdown-merge thread recommends --quiet for routine use; that combination hides the collision entirely.7
Are Markdown link labels case-sensitive?
No. The CommonMark spec specifies that label matching uses a Unicode case fold.3 [Report] and [report] are the same key. In the test, case-variant labels collided in all nine configurations, following the same split as identical labels.1
What happens if I paste a paragraph without its footnote definition?
The reference renders as literal brackets. Claim A.[^1] without a matching [^1]: definition in the destination document renders as Claim A.[^1] — visible, unlinked text — in all seven footnote-capable configurations tested.1 Fix it by carrying the definition alongside the paragraph, or use pandoc --reference-location=block to keep definitions block-local.
What is the safest way to name footnote labels in Markdown?
Names that include a date and a note-specific counter — [^2026-11-10-a], [^2026-11-10-b] — survive merges safely because they are unique across the corpus by construction. For label syntax and character rules, the footnotes and citations guide covers the full set. Avoid numeric labels like [^1] in notes you expect to merge; they are the default in many apps and in pandoc's own rendered output, which makes collision the default outcome rather than the exception.
A label that works inside one note is not guaranteed to work inside every note it may enter.
If you keep notes in plain Markdown, mnmnote.com stores them locally on your own device — no account, no server, nothing to migrate.
Footnotes
-
Own measurement,
materials/receipts/out/tally.txtandfix.txt, 2026-11-14. Nine engine configurations: markdown-it 15.0.3 + markdown-it-footnote 4.0.0, commonmark.js 0.31.2, marked 18.2.0, micromark 4.0.3 + micromark-extension-gfm 3.0.0, Python-Markdown 3.11.3, mistune 3.4.0, pandoc 3.13 (static linux-amd64, sha25638aa33b3…bf646389) with-f markdownand-f gfm, GitHubPOST /markdown. Inputs pinned; scripts, outputs, and SHA256SUMS inmaterials/receipts/. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 -
CommonMark Spec 0.31.2 (2024-01-28), §4.7 Link reference definitions, Example 204; ed. John MacFarlane. https://spec.commonmark.org/0.31.2/#link-reference-definitions ↩ ↩2
-
CommonMark Spec 0.31.2, §6.3 Links (definition of matches). https://spec.commonmark.org/0.31.2/#matches ↩ ↩2 ↩3 ↩4 ↩5
-
MNMNOTE, "Footnotes and Citations in Plain Markdown," https://blog.mnmnote.com/posts/footnotes-and-citations-in-plain-markdown ↩
-
Python-Markdown source @3.11.3,
blockprocessors.pyandextensions/footnotes.py. https://github.com/Python-Markdown/markdown/blob/3.11.3/markdown/blockprocessors.py ↩ ↩2 ↩3 -
pandoc source,
src/Text/Pandoc/Logging.hs@3.13. https://github.com/jgm/pandoc/blob/3.13/src/Text/Pandoc/Logging.hs ↩ ↩2 -
Stack Overflow Q4779582, "Markdown and including multiple files," 2011-01-24, 356,449 views. https://stackoverflow.com/questions/4779582 ↩ ↩2 ↩3
-
Python-Markdown docs, Footnotes extension @3.11.3. https://python-markdown.github.io/extensions/footnotes/ ↩
-
pandoc User's Guide (MANUAL.txt) @3.13 (released 2026-10-26). https://pandoc.org/MANUAL.html#option--file-scope ↩ ↩2 ↩3 ↩4
-
Aaron Massey, answer 5529508 on SO Q4779582, posted 2011-04-03, score 316 (top-voted). https://stackoverflow.com/a/5529508 ↩
-
MNMNOTE, "What Fits in a Markdown Table Cell (and What Silently Disappears)," https://blog.mnmnote.com/posts/what-fits-in-a-markdown-table-cell-and-what-silently-disappears ↩