#369·defuddle

figcaption is flattened to plain text: links and footnote refs inside captions are lost

Author: TigrandzaCreated Aug 20, 2026Updated Aug 20, 2026

Summary

Inline markup inside <figcaption> is stripped during extraction. Links become bare text and footnote references lose their anchor, so a caption that cites a source in the original page cites nothing in the extracted output.

Body text in the same document keeps both, so the loss is specific to captions.

Reproduction

defuddle 0.19.2, node entry point + linkedom:

javascript
import { parseHTML } from 'linkedom';
import { Defuddle } from 'defuddle/node';

const fig =
  '<figure><img src="https://example.com/a.jpg" width="600" height="400">' +
  '<figcaption>In <a href="https://example.com/dijkstra">Dijkstra</a>\'s own words, ' +
  '"a formula is worth a thousand pictures."' +
  '<sup class="reference"><a href="#cite_note-1">[1]</a></sup></figcaption></figure>';
const filler = '<p>' + 'Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor. '.repeat(30) + '</p>';

const { document } = parseHTML(`<!doctype html><html><head><title>T</title></head><body><article>${fig}${filler}</article></body></html>`);
const r = await Defuddle(document, 'https://example.com/a');
console.log(r.content.match(/<figcaption>[\s\S]*?<\/figcaption>/)[0]);

Actual

xml
<figcaption>In Dijkstra 's own words, "a formula is worth a thousand pictures." [1]</figcaption>

Expected — same inline markup the body gets:

xml
<figcaption>In <a href="https://example.com/dijkstra">Dijkstra</a>'s own words, "a formula is worth a thousand pictures."<sup id="fnref:1"><a href="#fn:1">1</a></sup></figcaption>

Live page: https://en.wikipedia.org/wiki/Formula — the Dijkstra portrait caption cites reference 1 and links "A picture is worth a thousand words"; both are gone after extraction, leaving a dangling 1 at the end of the sentence.

Notes

  • The reference also misses the footnote standardization applied to <sup> refs in body text, so a reader cannot follow it even manually.
  • The Dijkstra 's spacing in the output is the separate inline-space injection issue filed alongside this one.