feat/anchors-alias-buildtime #37
@@ -29,14 +29,29 @@ async function walk(dir) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contrat : .reading p[id^="p-"]
|
// Contrat :
|
||||||
|
// - paragraphes citables : .reading p[id^="p-"]
|
||||||
|
// - alias web-natifs : .reading span.para-alias[id^="p-"]
|
||||||
function extractIds(html) {
|
function extractIds(html) {
|
||||||
if (!html.includes('class="reading"')) return [];
|
if (!html.includes('class="reading"')) return [];
|
||||||
const ids = [];
|
|
||||||
const re = /<p\b[^>]*\sid="(p-[^"]+)"/g;
|
|
||||||
let m;
|
|
||||||
while ((m = re.exec(html))) ids.push(m[1]);
|
|
||||||
|
|
||||||
|
const ids = [];
|
||||||
|
let m;
|
||||||
|
|
||||||
|
// 1) IDs principaux (paragraphes)
|
||||||
|
const reP = /<p\b[^>]*\sid="(p-[^"]+)"/g;
|
||||||
|
while ((m = reP.exec(html))) ids.push(m[1]);
|
||||||
|
|
||||||
|
// 2) IDs alias (spans injectés)
|
||||||
|
// cas A : id="..." avant class="...para-alias..."
|
||||||
|
const reA1 = /<span\b[^>]*\bid="(p-[^"]+)"[^>]*\bclass="[^"]*\bpara-alias\b[^"]*"/g;
|
||||||
|
while ((m = reA1.exec(html))) ids.push(m[1]);
|
||||||
|
|
||||||
|
// cas B : class="...para-alias..." avant id="..."
|
||||||
|
const reA2 = /<span\b[^>]*\bclass="[^"]*\bpara-alias\b[^"]*"[^>]*\bid="(p-[^"]+)"/g;
|
||||||
|
while ((m = reA2.exec(html))) ids.push(m[1]);
|
||||||
|
|
||||||
|
// Dé-doublonnage (on garde un ordre stable)
|
||||||
const seen = new Set();
|
const seen = new Set();
|
||||||
const uniq = [];
|
const uniq = [];
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
|
|||||||
@@ -141,7 +141,8 @@
|
|||||||
"p-134-358f5875",
|
"p-134-358f5875",
|
||||||
"p-135-c19330ce",
|
"p-135-c19330ce",
|
||||||
"p-136-17f1cf51",
|
"p-136-17f1cf51",
|
||||||
"p-137-d8f1539e"
|
"p-137-d8f1539e",
|
||||||
|
"p-8-e7075fe3"
|
||||||
],
|
],
|
||||||
"atlas/00-demarrage/index.html": [
|
"atlas/00-demarrage/index.html": [
|
||||||
"p-0-97681330"
|
"p-0-97681330"
|
||||||
|
|||||||
Reference in New Issue
Block a user