Bot:Gadget-figureSource.js: Difference between revisions

Content deleted Content added
Prose card tags: chunk section heading instead of the bare chunk number
Prose heading: walk to the FOLLOWING h6 (marker is a sibling line, not inside it); idempotent tagging
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 301 ⟶ 305:
} else {
// the chunk's SECTION HEADING, not the bare chunk number —
// "Key highlights", not "chunk 3". The anchor[c. spann; sitsp. insidem] marker
// therenders chunk's h6;as its ownOWN markerline textABOVE isthe notchunk's part of theh6 title(Common.css
// .ed-chunk), so the heading is a FOLLOWING sibling of the
// marker's block, not an ancestor.
var anchor = document.querySelector(
'span.ed-chunk[id$="-c' + entry.loc.chunk + '"]');
var hblk = anchor && (anchor.closest('h6p') || anchor);
iffor (hvar i = 0; blk && i < 4; i++) {
var cloneblk = hblk.cloneNode(true)nextElementSibling;
cloneif (!blk || blk.querySelector && blk.querySelectorAllquerySelector('.ed-chunk').forEach(function (s) {
s.remove()break; // ran into the next chunk
});
varif title(blk.tagName = clone.textContent.replace(/\s+/g,== ' H6').trim(); {
if ( var title) {= partsblk.pushtextContent.replace(/\s+/g, ' ').trim(title); }
if (title) { parts.push(title); }
break;
}
}
}