$1$2
')
.replace(//g, '')
.replace(/{embed=\/\/(.+?)=(.+?)}/g, '')
.replace(/{graph=([^}]+)}/g, '')
.replace(/{census_groups}<\/p>(.+?)
{\/census_groups}<\/p>/gms, mainPlusDetails(census_groups, false))
.replace(/
{census_comparisons}<\/p>(.+?)
{\/census_comparisons}<\/p>/gms, mainPlusDetails(census_comparisons, true))
.replace(/{json=([^=}]+)=([^=}]+)}/g, fetchJson)
.replace(/
{twemoji}<\/p>(.+?)
{\/twemoji}<\/p>/gms, (_, c) => c) // twemoji.parse(c)
+ ''
;
content = content.replace(/{table_of_contents}/g, generateToC(content));
const disableTwemoji = content.includes('
{disable_twemoji}
');
content = content.replace(/{disable_twemoji}<\/p>/g, '');
const titleMatch = content.match('
]*>([^<]+)
');
const title = titleMatch ? titleMatch[1] : null;
const imgMatch = content.match(']*>');
const img = imgMatch ? imgMatch[1] : null;
let intro = [];
for (let introMatch of content.matchAll(/]*>(.+?)<\/p>/gms)) {
const p = introMatch[1].replace(/(<([^>]+)>)/ig, '').replace(/\s+/g, ' ');
intro = [...intro, ...p.split(' ')];
}
return {
title,
img,
intro: intro.length ? intro.slice(0, 24).join(' ') : null,
content,
disableTwemoji,
}
} catch {
return {
content: null,
};
}
}