User talk:Ohconfucius/dashes.js
What follows is a fork of User:GregU/dashes.js (forked on 27 May 2020) The editor who developed the script is no longer active, and changes to Wikipedia have restricted who can edit the old script page.
Please see the edit history for User:GregU/dashes.js for attribution
Overview
editFix hyphens, dashes, and minus signs per MOS:DASH.
Installation
editTo install, add the following line to your personal JavaScript page:
importScript('User:Ohconfucius/dashes.js');
This tool can be used standalone until it is added to AutoEd and wikEd. This module should follow unicodify.js if it is used.
- If inside wikEd, you will need to hit the pencil icon to temporarily disable wikEd in order to use this tool.
- If using AutoEd, you will need to custom list your modules, including this script as one of the modules. It is currently not possible to use both AutoEd and dashes.js independently of each other.
Utilisation
editAfter installation, hit refresh in your browser. The installed script will add a "–" tab to the drop-down tab at the top, located between the 'watchlist star' and the search box (using the vector.js skin).
You can use the "–" tab when you're viewing an article or when you're already editing it. Pressing it will make the fixes, leaving you viewing the changes. You should review the changes because the tool will occasionally (rarely) make a mistake. You can undo changes or make your own changes, then hit "Save page" when done.
The user can disable these conversions by putting "nodashes" somewhere in the text—either temporarily or permanently. You can similarly add "scores" if the score-detection heuristic doesn't trigger automatically.
Testing page is at User:GregU/dashes.js/tests. Please report false positives on the talk page.
Dashes in template transclusions
editThe script User:GregU/dashes.js has a bug: it breaks usages of Template:Excerpt. Example: Special:Diff/983876004. Ohconfucius, could you please check if your fork of this script also has this bug? —andrybak (talk) 20:03, 16 October 2020 (UTC)
- I've tweaked the script. Hopefully it works now. -- Ohc ¡digame! 19:33, 17 October 2020 (UTC)
- Module:Excerpt and Module:Excerpt/portals now accept en (1–2) and em (1—2) dashes as alternatives, though hyphen-minus (1-2) is still preferred. (Posted belatedly as I only just identified the source of the dashes.) Certes (talk) 14:07, 24 December 2021 (UTC)
Aircraft naming conventions
editSee the recent discussion at WT:AutoWikiBrowser/Typos § Aircraft naming conventions. Hyphens are correct in aircraft models such as "ATR 42-300", "Dash 8-400"; "Boeing 737-800". Please could you tweak your script to avoid changing these to dashes. Thanks. Rosbif73 (talk) 09:39, 13 December 2020 (UTC)
eISSN
editThe script doesn't recognise the eISSN parameter in {{infobox journal}} as one that shouldn't be changed; it tries to change an accurate hyphen to an inaccurate dash which produces a broken link, presumably mistaking it for a date range. See for example City (journal), The Journal of Urology, Annual Review of Entomology. It seems to know not to do it when the eISSN isn't a plausible date range, as in Textual Practice, however. Fairly easily spotted and avoided, but I thought someone might want to know. – Arms & Hearts (talk) 12:21, 22 December 2020 (UTC)
Dashes script
editOhconfusius, User:GregU/dashes.js seems to be glitching. Several of us could not get it to work at Battle of Tippecanoe, and yet I was able to get it to work here and here. SandyGeorgia (Talk) 18:26, 18 January 2021 (UTC)
- @SandyGeorgia Yeah, that is something I have also been noticing every now and then. Sometimes, you are clicking the button, the page is left unchanged, but if you click it again, it works. On even different occasions, you need to save the page with the empty diff shown and click the button again, and then it magically works as intended. 𝟙𝟤𝟯𝟺𝐪𝑤𝒆𝓇𝟷𝟮𝟥𝟜𝓺𝔴𝕖𝖗𝟰 (𝗍𝗮𝘭𝙠) 16:14, 13 March 2021 (UTC)
The script seems to destroy a particular age template. Can this be fixed?
editWhen using the script on Big Three (tennis) it wrecks the age template in use, changing the minus signs to dashes. Can this be fixed or do I just need to be extra observant? Thanks. Fyunck(click) (talk) 05:02, 15 February 2021 (UTC)
messing up UTC time formatting
editHi,
If you take a look at this edit, the script is messing with UTC times: −08:00 is being transformed into – 08:00. Could you adjust to fix this? —Joeyconnick (talk) 22:58, 19 February 2021 (UTC)
Dash spacing
editI did not notice there was an updated version until now, but the GregU script sometimes incorrectly left spaces around dashes. Just posting this here to ask whether this has been fixed. 𝟙𝟤𝟯𝟺𝐪𝑤𝒆𝓇𝟷𝟮𝟥𝟜𝓺𝔴𝕖𝖗𝟰 (𝗍𝗮𝘭𝙠) 16:12, 13 March 2021 (UTC)
- @Ohconfucius Ping in case you didn't notice. ~~~~
User:1234qwer1234qwer4 (talk) 21:19, 17 September 2021 (UTC)
Interface-protected edit request on 14 March 2021
editThis edit request to User:GregU/dashes.js has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
User:GregU/dashes.js is unmaintained and the author is inactive. Would an int-admin mind redirecting this to the maintained fork, User:Ohconfucius/dashes.js? — The Earwig (talk) 03:35, 14 March 2021 (UTC)
- Not done @The Earwig: no, as this would result in users loading a script from someone they did not choose to trust to have scripts run for them; and if it is a fork there could be feature changes that the importing users don't want. If there are only some bug fixes, we could update the current page. Another possible option would be to move this to MediaWiki space and make it a community script (possibly on the way to becoming a gadget). One other option, a one-time mass-message could be sent to the current users about how they can "upgrade" to the new fork. — xaosflux Talk 04:28, 14 March 2021 (UTC)
- @Xaosflux: OK, thanks. I completely understand the security concern, but figured I would ask since it's been done before. No new features for this fork, just bugfixes—has come up as an issue before. Syncing would be fine, but it means we'll be back here whenever future fixes are made. Moving it to the MediaWiki namespace sounds reasonable. I would not support a mass-message since asking 773 users to edit their common.js is a lot of effort for something we can take care of for them. — The Earwig (talk) 04:43, 14 March 2021 (UTC)
- @The Earwig: if we do move this to mediawiki, we could possibly batch update all the current users to it. I don't love that approach, but it is doable. A downside is that the current maintainer would need to use edit requests for updates. Do you have any idea how popular this script is, because gadgetization could work (and I wouldn't even be opposed to changing the old script to a notice that the script has been deprecated and those that want to use it should remove it from their .js and activate the gadget instead). — xaosflux Talk 05:10, 14 March 2021 (UTC)
- @Xaosflux: I linked to Wikipedia:User scripts/Most imported scripts above; it's listed as the 12th most popular script by imports. I didn't mean to suggest a batch update if we move to the MediaWiki namespace, just a redirect. That seems to be the convention judging by User:Lupin/popups.js and User:AzaToth/twinkle.js. (The use of a warning in addition to an importScript seems inconsistent.) @Ohconfucius: what do you think about this? — The Earwig (talk) 05:17, 14 March 2021 (UTC)
- @The Earwig: I have no objection. I forked it because I use it often but it needed tweaks every now and again. I always ended up getting User:Plastikspork to make necessary changes. But I'm no programmer so I'd be pleased to hand the script over to the community. -- Ohc ¡digame! 08:13, 14 March 2021 (UTC)
- We could do a redirect to mediawiki; would protect the userpage to prevent that user from editing it. What is currently functionally different with the fork? — xaosflux Talk 12:48, 14 March 2021 (UTC)
- @The Earwig: I have no objection. I forked it because I use it often but it needed tweaks every now and again. I always ended up getting User:Plastikspork to make necessary changes. But I'm no programmer so I'd be pleased to hand the script over to the community. -- Ohc ¡digame! 08:13, 14 March 2021 (UTC)
- @Xaosflux: I linked to Wikipedia:User scripts/Most imported scripts above; it's listed as the 12th most popular script by imports. I didn't mean to suggest a batch update if we move to the MediaWiki namespace, just a redirect. That seems to be the convention judging by User:Lupin/popups.js and User:AzaToth/twinkle.js. (The use of a warning in addition to an importScript seems inconsistent.) @Ohconfucius: what do you think about this? — The Earwig (talk) 05:17, 14 March 2021 (UTC)
- @The Earwig: if we do move this to mediawiki, we could possibly batch update all the current users to it. I don't love that approach, but it is doable. A downside is that the current maintainer would need to use edit requests for updates. Do you have any idea how popular this script is, because gadgetization could work (and I wouldn't even be opposed to changing the old script to a notice that the script has been deprecated and those that want to use it should remove it from their .js and activate the gadget instead). — xaosflux Talk 05:10, 14 March 2021 (UTC)
- @Xaosflux: OK, thanks. I completely understand the security concern, but figured I would ask since it's been done before. No new features for this fork, just bugfixes—has come up as an issue before. Syncing would be fine, but it means we'll be back here whenever future fixes are made. Moving it to the MediaWiki namespace sounds reasonable. I would not support a mass-message since asking 773 users to edit their common.js is a lot of effort for something we can take care of for them. — The Earwig (talk) 04:43, 14 March 2021 (UTC)
dashes inside <chem> tags
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
In a recent edit [1] by @Bruce1ee:, the script changed dashes to hyphen inside a <chem>
tag. This broke the format of chemical equations causing a syntax error. <chem>
tags work just like <math>
tags and need the dashes to remain as ascii character.
Line 59 of the script has some code to prevent the script working inside math tags
var m = string.slice(pos).search(/<\/?(math|pre|code|tt|source|syntaxhighlight|gallery)\b/i);
if (m >= 0 && string.charAt(pos m 1) == '/')
return str; // don't break a <math> equation, or source code
Could this be extended to work for the chem tags as well. There is also a deprecated version of the chem tag <ce>
which suffers the same problem. Could that be added as well? --Salix alba (talk): 18:45, 25 March 2021 (UTC)
- Support -- Sorry, that was my mistake. I should have seen that the script broke the two chemical equations. —Bruce1eetalk 23:23, 25 March 2021 (UTC)
- Not done you didn't write and test new code ready for immediate update, but more so this is a personal user script you can ask the owner to update their script at User talk:Ohconfucius, if they want to it is up to them. — xaosflux Talk 00:39, 29 March 2021 (UTC)
@Ohconfucius, the script attempted to replace the hyphen in "Jangang-Jangang" by a dash for some reason – any idea why this would be the case? ~~~~
User:1234qwer1234qwer4 (talk) 21:20, 17 September 2021 (UTC)
- I don't know the reason behind this particular change, or which line of code is responsible, but will look into it. I suspect that it's related to the convention on our Manual of Style. -- Ohc revolution of our times 09:00, 18 September 2021 (UTC)
Screwing with the UTC in the infobox
editA long time and ongoing problem with this script is this. It turns −07:00 which is a blue link in the infobox to – 07:00 which is a red link. Also just removing the space after the "–" does not work as it is still a red link. The "−" must be restored. Thanks. CambridgeBayWeather, Uqaqtuq (talk), Huliva 16:50, 23 October 2021 (UTC)
Error
editSince today, the "–" tab at the drop-down tab is replaced by "auto ed". Dashes doesn't work anymore. Grimes2 (talk) 20:23, 18 August 2022 (UTC)
- @Grimes2: the same a few hour ago happened to my fork of this script, at User:BrownHairedGirl/biogdashes.js. The menu entry is now "auto ed". BrownHairedGirl (talk) • (contribs) 04:03, 19 August 2022 (UTC)
- The "auto ed" entry shows the error message "AutoEd/core.js: autoEdFunctions is undefined". It doesn't work anymore. Grimes2 (talk) 04:28, 19 August 2022 (UTC)
- Yep.... this is a vital tool. Can it be fixed? Fyunck(click) (talk) 07:09, 19 August 2022 (UTC)
- It must be something at the Mediawiki end, for there haven't been any changes in the code. I'm awaiting help at WP:VPT -- Ohc revolution of our times 09:31, 19 August 2022 (UTC)
- Came here to make the same complaint, glad folks are already aware. Watching this with interest. Vanamonde (Talk) 14:45, 19 August 2022 (UTC)
- Now fixed. Many thanks to User:William Avery for the workaround proposed. -- Ohc revolution of our times 11:26, 20 August 2022 (UTC)
- Thank you. Grimes2 (talk) 11:39, 20 August 2022 (UTC)
- "Auto ed" is still appearing for me. Ham II (talk) 18:20, 20 August 2022 (UTC)
- Still dead for me using Chrome. Fyunck(click) (talk) 20:26, 20 August 2022 (UTC)
- Unless I'm missing something, it doesn't appear that either of you has User:Ohconfucius/dashes.js installed. You both have User:GregU/dashes.js. (Note that User talk:GregU/dashes.js redirects here.) BTW, Ohconfucius, I would recommend changing the edit summary (autoEdTag) to leave a link to your script instead of GregU's. MANdARAX XAЯAbИAM 00:12, 21 August 2022 (UTC)
- Well heck... that fixed it for me. What's interesting is that installing that script also made the GregU script work. I suddenly had two minus signs at the page top until I removed the GregU script. Thanks @Mandarax:. Fyunck(click) (talk) 02:38, 21 August 2022 (UTC)
- Works for me now too – thank you! I've still got the two dashes in the drop-down menu, though – I can't find where the duplicate I need to remove is. Ham II (talk) 07:54, 21 August 2022 (UTC)
- Ah, the duplicate was an instance of GregU's script in meta:User:Ham II/global.js; I've removed it from there now. Ham II (talk) 08:12, 21 August 2022 (UTC)
- @Ham II: I also can't find the duplicate :( --SuperJew (talk) 04:50, 25 August 2022 (UTC)
- SuperJew, you've got the correct version in your common.js. To fix the problem, remove the GregU version from your vector.js (or you can {{Db-u1}} the file since that's the only thing there). MANdARAX XAЯAbИAM 21:15, 25 August 2022 (UTC)
- @Mandarax: Thank you so much! For future reference, how did you find that? Or are you just familiar with all the pages scripts might be accessed via? --SuperJew (talk) 05:12, 26 August 2022 (UTC)
- You're welcome. To find it, I checked your userspace for
common.js
as well as.js
files for skins such as monobook and vector. MANdARAX XAЯAbИAM 06:24, 26 August 2022 (UTC)
- You're welcome. To find it, I checked your userspace for
- @Mandarax: Thank you so much! For future reference, how did you find that? Or are you just familiar with all the pages scripts might be accessed via? --SuperJew (talk) 05:12, 26 August 2022 (UTC)
- SuperJew, you've got the correct version in your common.js. To fix the problem, remove the GregU version from your vector.js (or you can {{Db-u1}} the file since that's the only thing there). MANdARAX XAЯAbИAM 21:15, 25 August 2022 (UTC)
- I'm also using Chrome and it was still not working. I noticed that I had GregU/dashes.js installed and replaced that with Ohconfucius/dashes.js – that sorted it! Schwede66 10:25, 21 August 2022 (UTC)
- @Ham II: I also can't find the duplicate :( --SuperJew (talk) 04:50, 25 August 2022 (UTC)
- Ah, the duplicate was an instance of GregU's script in meta:User:Ham II/global.js; I've removed it from there now. Ham II (talk) 08:12, 21 August 2022 (UTC)
- Unless I'm missing something, it doesn't appear that either of you has User:Ohconfucius/dashes.js installed. You both have User:GregU/dashes.js. (Note that User talk:GregU/dashes.js redirects here.) BTW, Ohconfucius, I would recommend changing the edit summary (autoEdTag) to leave a link to your script instead of GregU's. MANdARAX XAЯAbИAM 00:12, 21 August 2022 (UTC)
- Still dead for me using Chrome. Fyunck(click) (talk) 20:26, 20 August 2022 (UTC)
- Now fixed. Many thanks to User:William Avery for the workaround proposed. -- Ohc revolution of our times 11:26, 20 August 2022 (UTC)
- Came here to make the same complaint, glad folks are already aware. Watching this with interest. Vanamonde (Talk) 14:45, 19 August 2022 (UTC)
- It must be something at the Mediawiki end, for there haven't been any changes in the code. I'm awaiting help at WP:VPT -- Ohc revolution of our times 09:31, 19 August 2022 (UTC)
- Yep.... this is a vital tool. Can it be fixed? Fyunck(click) (talk) 07:09, 19 August 2022 (UTC)
- The "auto ed" entry shows the error message "AutoEd/core.js: autoEdFunctions is undefined". It doesn't work anymore. Grimes2 (talk) 04:28, 19 August 2022 (UTC)
- This is also the case for me, on Firefox. –♠Vamí_IV†♠ 09:29, 24 August 2022 (UTC)
- To fix the problem, in User:Vami IV/common.js, replace
GregU
withOhconfucius
. MANdARAX XAЯAbИAM 21:29, 25 August 2022 (UTC)- Ahah, all good now. Thanks, friend. –♠Vamí_IV†♠ 01:32, 26 August 2022 (UTC)
- To fix the problem, in User:Vami IV/common.js, replace
seems to have stopped working?
editI tried to run the dashes script on this revision and it found nothing. But in fact, there were four year ranges using just "-" and not en-dashes that it should have picked up on. —Joeyconnick (talk) 21:16, 18 December 2022 (UTC)
- Figured out the issue, although I have no idea why it's an issue: if the new syntax highlighter is on, this script won't run. Turn it off: runs as expected. Is also screwing with this script: User:Meteor sandwich yum/Tidy citations.js. —Joeyconnick (talk) 21:32, 20 December 2022 (UTC)
affecting UTC offsets when it shouldn't be
editHi... any chance we can "protect" the following:
<actual minus sign or hyphen-minus>\d{1,2}:\d\d
when in a statement dealing with UTC like:
|utc_offset=
An example of the script changing things of this sort in error can be found here. —Joeyconnick (talk) 19:41, 6 March 2023 (UTC)
This script breaks template:CFB Team Depth Chart
editThis template has a field |dscheme= that contains team formation in the format "n-n". The script incorrectly changes this to "n–n", which breaks the template and causes it to display incorrectly (a whole section out of the output just disappears). -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 22:17, 12 July 2023 (UTC)
Fix if statement
editThis edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
@Ohconfucius: The if statement on line 163 is not really correct. All of the rest should also be bracketed to enable using it WITH AutoEd, else you have two hyphen links that both appear like the dashes fix but apply all of AutoEd. Aaron Liu (talk) 16:58, 13 September 2023 (UTC)
- @Aaron Liu:Thanks for the heads up. I get the drift of your request but programming is not my strong suit. It would be great if you could let me have the necessary code, showing what needs to be replaced with what. Regards, -- Ohc revolution of our times 07:45, 15 September 2023 (UTC)
- So, add a } as the absolute bottom of the file and a { at the end of line 163. Thanks! Aaron Liu (talk) 11:13, 15 September 2023 (UTC)
- Not done (as to the interface-administrator immediate edit request). @Ohconfucius: is engaged in this discussion about their personal script already. — xaosflux Talk 02:04, 16 September 2023 (UTC)
eISSN Again
editThe #eISSN issue raised nearly three years ago is still an issue per e.g. Special:Diff/1178112453. 2603:8001:4542:28FB:AD57:8D2F:2FB1:7F6A (talk) 23:25, 1 October 2023 (UTC)
not working on android device browsers?
edithello @GregU: i have tested both mull (91.1.0) and samsung internet (14.2.3.14) browser on page at User:GregU/dashes.js/tests using both source code and visual mode also. it is showing no difference. you can find my common.js. -28au21 (talk) 12:40, 31 August 2021 (UTC)
Big when interacting with CFB Team Depth Chart
editHi Ohconfucius. There is a bug with how this script is interacting with {{CFB Team Depth Chart}}. The template requires numbers separated by a hyphen, using an endash causes the template to incorrectly display the data in the articles where it is used. See this edit as an example, search CFB Team Depth Chart or DScheme (the field effected in this instance). I've made a request at the templates talk page about this issue previously, but I don't it's a highly watched page. -- LCU ActivelyDisinterested ∆transmissions∆ °co-ords° 23:45, 4 February 2023 (UTC)
- @Ohconfucius Maybe add "football" to the score-detection heuristic? Sorry for the pings, somebody's told me that there were a lot of unaddressed problems here when I tried to add this script to the "Complete" autoEd preset. There seems to also be #Issue with dashes in reference names and #eISSN. Aaron Liu (talk) 01:18, 20 January 2024 (UTC)
Bug that breaks comment
edit@Ohconfucius: Hi there! In this edit to Stephen Hammond, the dashes script broke a comment in a reference. Could you please tweak the script so this doesn't happen in the future? Thanks! GoingBatty (talk) 18:23, 26 October 2023 (UTC)
- @Ohconfucius This seems like a problem. Maybe a negative lookahead? Aaron Liu (talk) 01:04, 20 January 2024 (UTC)
Issue with dashes in reference names
editHi @Ohconfucius: – a few days ago I fixed a reference error caused by this edit, made with this script. I think that the script shouldn't be changing unnamed parameters of the {{r}} template, since they are reference names which are character-sensitive (on the other hand it should be changing arguments of the |pages=
etc. parameters since they are page ranges). Is it possible to upgrade the script to avoid this kind of problem? Pinging User:Schwede66 who was using the script at the time. Thanks, Wham2001 (talk) 10:52, 16 December 2023 (UTC)
Can't get it to work
edit@Ohconfucius Hallo, I think I've added the right line to my .js, and I think I've refreshed my Firefox screen (a couple of times, each), but I can't seem to get it to show the "-" on the edit bar. Any advice? Sorry if I'm missing something obvious. PamD 19:50, 12 December 2023 (UTC)
- @PamD It should be in the same place as the "Move" button is. Aaron Liu (talk) 01:12, 20 January 2024 (UTC)
Suggestion: Do standalone check on document load
edit$.when( $.ready, mw.loader.using( 'jquery.textSelection' ) ).then(function() {
mw.loader.load(AutoEd_baseurl 'core.js'); //Imports the "framework" script needed to make this function
});
@Ohconfucius All official AutoEd packs use this code, so it is probably superior.[citation needed] Could the standalone-ing part of the code also be converted, like this?
$.when( $.ready, mw.loader.using( 'jquery.textSelection' ) ).then(function() {
if (importScript("Wikipedia:AutoEd/core.js")) { // if not otherwise using AutoEd
console.log('imported')
function autoEdFunctions() {
var txt = document.editform.wpTextbox1;
var str = txt.value.
replace(/—/g, '—').
replace(/–/g, '–'). // simplify core regexes
replace(/−/g, '−');
var newstr = autoEdDashes( str );
if (newstr != str) { // don't alter encoding style if no fixes
txt.value = newstr;
autoEdTag = "fixed [[MOS:DASH|dashes]] using [[User:Ohconfucius/dashes.js]]";
}
}
autoEdLinkName = "–";
autoEdLinkHover = "Fix dashes, hyphens, and minus signs";
autoEdTag = "";
}
});
Aaron Liu (talk) 01:44, 22 December 2023 (UTC)
- @Aaron Liu:I updated the script with the code you suggested, but the execution fails displaying an error message:
"AutoEd/core.js: autoEdFunctions is undefined"
. Did I do something wrong? -- Ohc revolution of our times 13:35, 28 December 2023 (UTC)- Ok, think I've fixed it:Aaron Liu (talk) 16:36, 28 December 2023 (UTC)
$.when( $.ready ).then(function() { if (importScript("Wikipedia:AutoEd/core.js")) { // if not otherwise using AutoEd console.log('imported'); window.autoEdFunctions = function() { var txt = document.editform.wpTextbox1; var str = txt.value. replace(/—/g, '—'). replace(/–/g, '–'). // simplify core regexes replace(/−/g, '−'); var newstr = autoEdDashes( str ); if (newstr !== str) { // don't alter encoding style if no fixes txt.value = newstr; autoEdTag = "fixed [[MOS:DASH|dashes]] using [[User:Ohconfucius/dashes.js]]"; } }; autoEdLinkName = "–"; autoEdLinkHover = "Fix dashes, hyphens, and minus signs"; autoEdTag = ""; } });
- Hi @Ohconfucius, could you please implement this? Also, why does User talk:Ohconfucius/dashes redirect to some obscure header page? Aaron Liu (talk) 01:54, 14 January 2024 (UTC)
- Ok, think I've fixed it: