walter-boente_book-collection/js/these.js

38 lines
1 KiB
JavaScript
Raw Normal View History

2026-04-09 21:52:21 +02:00
import { Handler } from '/csspageweaver/lib/paged.esm.js';
export default class thesis extends Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
beforeParsed(content){
console.log("Thesis ------- ");
2026-04-09 22:03:28 +02:00
const strongs = content.querySelectorAll('strong');
strongs.forEach(strong => {
if (/^these\s+\d+/i.test(strong.textContent.trim())) {
const parent = strong.closest('p');
if (parent) {
parent.classList.add('p-these');
}
}
});
const theseParas = content.querySelectorAll('.p-these');
theseParas.forEach(p => {
let next = p.nextElementSibling;
while (next && next.tagName.toLowerCase() === 'ol') {
next = next.nextElementSibling;
}
if (!next || !next.classList.contains('p-these')) {
p.classList.add('p-these-last');
}
});
2026-04-09 21:52:21 +02:00
}
}