Bot:Gadget-figureSource.js: Difference between revisions

Content deleted Content added
Prose card tags: chunk section heading instead of the bare chunk number
Prose address: section h2 + chunk title (title lives in the marker paragraph)
 
(One intermediate revision by the same user not shown)
Line 203:
var idx = 0, node;
while (idx < list.length && (node = walker.nextNode())) {
if (node.parentElement.closest('table,// .fig-card,src .figin the guard = idempotency: re-banner')) {running continue;the }tagger
// (staging-copy injection during verification) must never
// nest a second wrapper inside an already-tagged figure
if (node.parentElement.closest(
'table, .fig-card, .fig-banner, .fig-src')) { continue; }
if (chunkOf(node) !== parseInt(chunk, 10)) { break; }
var at, from = 0;
Line 300 ⟶ 304:
if (label && label !== el) { parts.push(cellText(label)); }
} else {
// theAddress chunk'sfor SECTIONa HEADINGprose figure, notouter the-> bareinner: chunk numberthe enclosing
// "Keysection highlights"heading, notthen "chunkthe 3".CHUNK TheTITLE anchor spanwhich sitslives insideINSIDE the
// the chunkmarker's h6;own its<p> own("[c. marker3; textp. is1] notGross partwritten ofpremiums the title.and
// underlying earnings"), so it is the paragraph text minus the
// .ed-chunk span. "chunk 3" appears nowhere: readers get words.
var anchor = document.querySelector(
'span.ed-chunk[id$="-c' + entry.loc.chunk + '"]');
var hblk = anchor && anchor.closest('h6p');
if (hblk) {
var cloneup = hblk.cloneNode(true)previousElementSibling;
while (up && !/^H[1-4]$/.test(up.tagName)) {
up = up.previousElementSibling;
}
if (up) {
parts.push(up.textContent.replace(/\s+/g, ' ').trim());
}
var clone = blk.cloneNode(true);
clone.querySelectorAll('.ed-chunk').forEach(function (s) {
s.remove();