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
Fix hyphens, dashes, and minus signs per MOS:DASH.
To 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.
After 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.
The 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)
See 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)
The 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)
Ohconfusius, 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)
When 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)
Hi,
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)
I 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)
This 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)
This 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)
@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)
A 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)
Since 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)
common.js
as well as .js
files for skins such as monobook and vector. MANdARAX XAЯAbИAM 06:24, 26 August 2022 (UTC)GregU
with Ohconfucius
. MANdARAX XAЯAbИAM 21:29, 25 August 2022 (UTC)
I 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)
Hi... 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 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)
This 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)
The #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)
hello @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)
Hi 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: 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)
Hi @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)
@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)
$.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)
"AutoEd/core.js: autoEdFunctions is undefined"
. Did I do something wrong? -- Ohc revolution of our times 13:35, 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 = "";
}
});