Bot:Gadget-figureSource.js: Difference between revisions

Content deleted Content added
Prose heading: walk to the FOLLOWING h6 (marker is a sibling line, not inside it); idempotent tagging
Prose address: section h2 + chunk title (title lives in the marker paragraph)
 
Line 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 [c. n;which p.lives m]INSIDE markerthe
// rendersmarker's asown its<p> OWN("[c. line3; ABOVEp. the1] chunk'sGross h6written (Common.csspremiums and
// .ed-chunkunderlying earnings"), so the headingit is athe FOLLOWINGparagraph siblingtext ofminus the
// marker's.ed-chunk block,span. not"chunk an3" ancestorappears nowhere: readers get words.
var anchor = document.querySelector(
'span.ed-chunk[id$="-c' + entry.loc.chunk + '"]');
var blk = anchor && (anchor.closest('p') || anchor);
forif (var i = 0; blk && i < 4; i++) {
blkvar up = blk.nextElementSiblingpreviousElementSibling;
ifwhile (!blk || blk.querySelectorup && blk!/^H[1-4]$/.querySelectortest('up.ed-chunk'tagName)) {
break;up = // ran into the next chunkup.previousElementSibling;
}
if (blk.tagName === 'H6'up) {
var title = blkparts.push(up.textContent.replace(/\s+/g, ' ').trim());
if (title) { parts.push(title); }
break;
}
var clone = blk.cloneNode(true);
clone.querySelectorAll('.ed-chunk').forEach(function (s) {
breaks.remove();
});
var title = clone.textContent.replace(/\s+/g, ' ').trim();
if (title) { parts.push(title); }
}
}