fix(funbox): fix Wikipedia funbox sometimes producing double spaces (FortPile) (#4814)

* fix: prepone non-ascii characters removal

* also replacing fancy symbols

---------

Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
FortPile 2023-11-27 21:16:27 +08:00 committed by GitHub
parent f0e26b5491
commit 4fa6647b9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,16 +106,20 @@ export async function getSection(language: string): Promise<Section> {
// Remove invisible characters
sectionText = sectionText.replace(/[\u200B-\u200D\uFEFF]/g, "");
// replace any fancy symbols
sectionText = Misc.cleanTypographySymbols(sectionText);
// Remove non-ascii characters for English articles
if (urlTLD === "en") {
sectionText = sectionText.replace(/[^\x20-\x7E]+/g, "");
}
// Convert all whitespace to space
sectionText = sectionText.replace(/\s+/g, " ");
// Removing whitespace before and after text
sectionText = sectionText.trim();
if (urlTLD === "en") {
sectionText = sectionText.replace(/[^\x20-\x7E]+/g, "");
}
const words = sectionText.split(" ");
const section = new Section(