mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 07:16:17 +08:00
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:
parent
f0e26b5491
commit
4fa6647b9c
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue