Work around missing titles in all recent Wikimedia scrapes

This commit is contained in:
Jaifroid 2023-08-25 08:15:33 +01:00
parent 882818b49d
commit 26b96dd02a

View File

@ -4941,8 +4941,8 @@ function displayArticleContentInContainer (dirEntry, htmlArticle) {
// Put site.js in the correct position
htmlArticle = htmlArticle.replace(/(<script\b[^>]+\/site\.js["']><\/script>\s*)((?:[^<]|<(?!\/body))+)/, '$2$1');
// @TODO Remove when fixed in https://github.com/openzim/mwoffliner/issues/1872
// Add missing title to Wikivoyage articles for post June 2023 scrapes
htmlArticle = /wikivoyage_en/.test(appstate.selectedArchive._file.name) && !/<h1\b[^>]+section-heading/i.test(htmlArticle) ? htmlArticle.replace(/(<section\sdata-mw-section-id="0"[^>]+>\s*)/i, '$1<h1 style="margin:10px 0">' + dirEntry.getTitleOrUrl() + '</h1>') : htmlArticle;
// Add missing title to WikiMedia articles for post June 2023 scrapes
htmlArticle = !params.isLandingPage && !/<h1\b[^>]+section-heading/i.test(htmlArticle) ? htmlArticle.replace(/(<section\sdata-mw-section-id="0"[^>]+>\s*)/i, '$1<h1 style="margin:10px 0">' + dirEntry.getTitleOrUrl() + '</h1>') : htmlArticle;
}
// Gutenberg ZIMs try to initialize before all assets are fully loaded. Affect UWP app.