User talk:Novem Linguae/Scripts/DraftCleaner.js

MOS:REFPUNCT: Reference, whitespace, period

edit

Hi, @Novem Linguae! I just tried running DraftCleaner on List of National Cultural Treasures in the Philippines and noticed that it doesn't fix cases where a reference appears before punctuation where a space also appears between them (e.g. <ref> .). Could this be something worth fixing/adding in?

Pinging you here per your talk page banner. Chlod (say hi!) 16:42, 3 November 2024 (UTC)Reply

Diff.Novem Linguae (talk) 09:38, 2 December 2025 (UTC)Reply
@Chlod. I searched https://en.wikipedia.org/w/index.php?title=List_of_National_Cultural_Treasures_in_the_Philippines&action=edit&oldid=1255189260 (the oldid of the DraftClaner result) for > ., expecting to find this since it sounds like DraftCleaner didn't fix it, and couldn't find anything. Any other details you can provide? –Novem Linguae (talk) 09:42, 2 December 2025 (UTC)Reply
Sorry for the confusion, @Novem Linguae. I fixed the > . manually before publishing but I forgot to change the edit summary, which made this look like it was properly detected and fixed. I copied the old revision into my sandbox and you can see the missing fix here on the first few lines of the diff. Chlod (say hi!) 13:03, 2 December 2025 (UTC)Reply
Thanks for those additional details. I fixed the first half of this bug just now by adding \s* to the regex. The second half of this bug is adding support for <ref name="test" /> style refs. Probably too much work to do this morning. But here's the relevant code in case you get nerd sniped: 1, 2. –Novem Linguae (talk) 15:16, 2 December 2025 (UTC)Reply

Category escaping

edit

Hi, I noticed here that DraftCleaner redundantly applied WP:COLONTRICK to the category even though it was already covered by {{draft categories}}, which kind of misses the point of the latter. Any chance of a fix? Paradoctor (talk) 21:04, 18 October 2025 (UTC)Reply

 Done. I did it the hacky way. If {{Draft categories}} is present, it doesn't try to do any colon tricks. This was easier to program than checking to see if the category is inside of said template. –Novem Linguae (talk) 09:34, 2 December 2025 (UTC)Reply
Thanks, much appreciated. Paradoctor (talk) 09:44, 2 December 2025 (UTC)Reply

convertDoubleSpacesToSingleSpaces

edit

May I respectfully request that the convertDoubleSpacesToSingleSpaces() functionality be removed from this script? My understanding is that single and double spaces after sentences are rendered exactly the same way, so edits like this are just noise. RoySmith (talk) 01:05, 16 January 2026 (UTC)Reply

Hey there. I think convertDoubleSpacesToSingleSpaces is OK to leave on. It is one of many useful heuristics for cleaning up subpar draft wikicode. Most prose both on Wikipedia and in real life has converted from double spaces to single spaces.
The diff given seems unusual since DraftCleaner isn't usually run on FAs, and usually more than one heuristic is run per diff.
DraftCleaner has the user preview their edit each time, so the user has the option of not running the edit if the edit is purely cosmetic tweaking of the wikicode.
Am open to changing my mind if more people request it. Anyone should feel free to chime in. –Novem Linguae (talk) 05:33, 16 January 2026 (UTC)Reply