User talk:Ucucha/HarvErrors

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Bad Templates[edit]

Could this script be modified to edit the article and add {{citation not found}} after the bad template? This puts the article in a maintenance category so that all these errors can be found and fixed. ---- CharlesGillingham (talk) 10:46, 3 June 2011 (UTC)[reply]

That might be a suitable task for a bot, but would change the purpose of this script a little too far. Perhaps similar logic can be added to tools like AutoEd, RefTools, and AWB. Ucucha 11:01, 3 June 2011 (UTC)[reply]

Help pages[edit]

This is a very useful script— it should be proposed as a gadget.

I suggest we add a link to a help page for each message; see Help:Cite errors. ---— Gadget850 (Ed) talk 15:42, 6 August 2011 (UTC)[reply]

If appropriate help pages are written, I'd be happy to add links. I'm not sure it's necessary, though, since people who see the messages will have installed the script and will be able to find the documentation at User:Ucucha/HarvErrors, which explains the errors (improvements to that documentation are welcome, of course). Ucucha (talk) 15:52, 6 August 2011 (UTC)[reply]
I usually direct people to Template:Harv#Wikilink to citation does not work. --Redrose64 (talk) 17:32, 6 August 2011 (UTC)[reply]

After helping folks fix problems, I would like to create a separate help page, Help:Harv errors and have the error messages link there. Could we also show the anchor in the second message? ---— Gadget850 (Ed) talk 10:07, 21 April 2012 (UTC)[reply]

Unused Notes[edit]

Maybe {{note|...}} could display a warning if the note is not being used in the article? Gadget850 suggested here that I could contact you about this. --82.170.113.123 (talk) 09:53, 29 June 2013 (UTC)[reply]

There is no way for the template to detect use. If you install this script, then it will detect use of {{ref}} and {{note}}. --  Gadget850 talk 10:39, 29 June 2013 (UTC)[reply]

Strange effect in edit summary - left-hand side of diffs[edit]

See the edit summary on the left-hand side of this diff: it throws Harv error: link from #CITEREF_and_havnb_and_CITEREF_and_CS1 doesn't point to any citation. However, if you follow the Previous edit link, the same edit summary is shown on the right-hand side, but without the red error message. --Redrose64 (talk) 23:49, 20 December 2013 (UTC)[reply]

Unused anchors[edit]

When one uses the Citation template, or simply sistematically adds ref = harv to Cite template occurences, all Citation/Cite with ref=harv occurences are flagged if they are not actually referenced in the article. This is quite annoying, since often the articles do list unreferenced bibliography and adhere to a standard of using Citation or Cite with ref=harv. Could this be either turned off by a flag, or an alternative version of the script created, or make a low profile warning instead of an error?

Lgfcd (talk) 19:33, 8 May 2014 (UTC)[reply]
(talk page stalker) @Lgfcd: You can add some CSS to Special:MyPage/common.css. Use one of the following two lines:
span.citation strong.error { display: none; }
span.citation strong.error { font-weight: normal; }
Use the first one to completely hide the messages like Harv error: There is no link pointing to this citation. The anchor is named CITEREFFooBar2014. - use the second one to keep the message but to show it in normal font instead of boldface. --Redrose64 (talk) 22:43, 8 May 2014 (UTC)[reply]
Your second tip is nice, but then I see both real errors and unused anchors with the same low key format. As for the first, I fear I did not understand — why hide all error warnings? Would it not be the same thing as uninstalling the script?
Lgfcd (talk) 22:19, 9 May 2014 (UTC)[reply]
The script generates two types of error message, and my first line of CSS above hides only the "There is no link pointing to this citation" messages. The ones like Harv error: link from #CITEREFFooBar2014 doesn't point to any citation. are still visible, so the script still needs to be enabled. These messages are not toned down by the second line of CSS - they remain bold. I don't think that it's possible for the script to distinguish between real errors and unused anchors. The way that I handle it is to leave |ref=harv out of any {{cite book}} that I do not intend to use for Shortened footnotes - see NBR 224 and 420 Classes#Further reading, where none have |ref=harv; in contrast to those books in the References section immediately above, all of which have |ref=harv. --Redrose64 (talk) 00:59, 10 May 2014 (UTC)[reply]
But this doesn't solve the problem when CS2 style citations are used, either via {{citation}} or via | added to cite templates. It simply isn't an error to have unused anchors in such cases. Peter coxhead (talk) 17:54, 30 January 2016 (UTC)[reply]
I actually find it useful to know which citations have been used and which not. My problem is that some editors who use this have been flagging these as errors and asking me to fix it, or worse, in one case deleting them all and leaving me a note that I was violating WP procedures! --Michael Goodyear (talk) 22:30, 30 January 2016 (UTC)[reply]
You can turn off the problematic messages by adding
window.checkLinksToCitations = false;
before the call to User:Uchacha/HarvErrors.js in your common.js. But this doesn't solve the problem that other editors believe these are errors. Peter coxhead (talk) 10:28, 31 January 2016 (UTC)[reply]

@Ucucha: since it is not an error to have anchors without citations linking to them, please could you at least change the text of the "error" message to read "Harv warning: There is no link pointing to this citation. ..." rather than "Harv error: ..." Peter coxhead (talk) 10:28, 31 January 2016 (UTC)[reply]

Makes sense, I've made that change. Ucucha (talk) 17:32, 31 January 2016 (UTC)[reply]
Thanks! Peter coxhead (talk) 21:32, 31 January 2016 (UTC)[reply]
Thanks! --Michael Goodyear (talk) 19:19, 3 February 2016 (UTC)[reply]

Occasional bug in article previews[edit]

On some pages (but not others), clicking the preview button never loads a preview. I believe I have traced the problem to line 14 of this script, where I'm getting a TypeError because elem.parentNode is null. Daask (talk) 20:06, 31 January 2018 (UTC)[reply]

What page(s), for example? And are you using HarvErrors or HarvErrors2? (I don't think Ucucha is around these days) Lingzhi ♦ (talk) 00:56, 1 February 2018 (UTC)[reply]

Show button bug[edit]

Hello Ucucha, THANK YOU for an awesome tool. Instead of importing, I copied the current state of the code to User:NewsAndEventsGuy/common.js, where I also have copied User:Cumbril/RefConsolidate_start.js. Recently another editor added some harv cites on a talk page (making pipes) but did not provide a bibliography of sources (so there were no anchors). Your script worked GREAT in terms of flagging the mistakes. However, for some bizarre reason it also disabled Template:Show button everywhere on the page. Some diffs you can experiment with, and the debug discussion that leads me here can be found here. Of course the problem might be with the other script, but I thought I'd message you first. Thanks for any help! NewsAndEventsGuy (talk) 23:35, 8 August 2019 (UTC)[reply]

(talk page watcher) @NewsAndEventsGuy: I have no problem with show buttons when using the HarvErrors script, and so I found your comments at Template talk:WikiProject banner shell#Template-protected edit request on 7 August 2019 puzzling. But I see from User:NewsAndEventsGuy/common.js that you have not followed the directions at User:Ucucha/HarvErrors - don't copy the script, you should import it instead, as I did. So the problem may be due to that usage. If that is not the case, the problem must be with the other code that you have added to common.js. --Redrose64 🌹 (talk) 07:50, 9 August 2019 (UTC)[reply]
Bottom line, Redrose64 is right on the money....this behavior is conclusively related to copy-pasting the source code for Harv Errors instead of using the "import" line. Why copy-pasting should make a difference compared to simply importing is puzzling to me. I've long viewed copy-pasting as a "good practice" security thing, just like I don't plug random flash drives into my work computer. If you'd like to double check my testing, the step by step I did to isolate this can be found in the edit summaries of version history for User:NewsAndEventsGuy/common.js. Note that the other script (Reference Organizer) also says to use the import function, and when I copy pasted that one there was no issue. Ucucha, why would the import function work and copy pasting the same thing not work? Or is there additional code or customization on your end behind the scenes that we only get the benefit of, if we use the import function? Thanks again for a great tool NewsAndEventsGuy (talk) 09:54, 9 August 2019 (UTC)[reply]

A lot more testing has zeroed in on the issue. Details, and hopefully discussion, can be found at the talk page for Wikipedia Project javascript, in the thread Importscript vs just putting code in common.js. @Redrose64: thanks for the observation above. If you can shed any further light please add it to that thread. NewsAndEventsGuy (talk) 19:38, 12 August 2019 (UTC)[reply]

Only show errors, don't show warnings?[edit]

Would it be possible to have the option to only show errors, rather than errors and warnings? Headbomb {t · c · p · b} 18:45, 17 February 2020 (UTC)[reply]

@Headbomb: Try this CSS rule:
cite.citation strong.warning { display: none; }
it goes in either Special:MyPage/common.css (if you have one) or Special:MyPage/skin.css. --Redrose64 🌹 (talk) 09:27, 18 February 2020 (UTC)[reply]
I suppose that's an option. I was just wondering if there was a way to give that option more straight-fowardly for newbies. Still, I'll take it. Headbomb {t · c · p · b} 09:31, 18 February 2020 (UTC)[reply]
Turns out User:Svick/HarvErrors.js, the original script, is exactly what I had in mind. Headbomb {t · c · p · b} 05:23, 28 March 2020 (UTC)[reply]

Superseded[edit]

Has this script become redundant now that the citation templates appear to be doing harv error detection? Does this script provide an extra utility that I'm missing? If not, job well done—this has been a vital script for many years and its wider adoption has proven its need. Thank you! czar 01:19, 28 March 2020 (UTC)[reply]

The point is to make it redundant (or at least to make User:Svick/HarvErrors.js redundant, which only flags errors, and doesn't warn about things that aren't guaranteed to be broken). The current implementation has issues, so that might get reverted before a fix is found. Headbomb {t · c · p · b} 05:22, 28 March 2020 (UTC)[reply]

Did you change the coding?[edit]

I've used this tool for years, and it never showed errors unless I have something coded "ref=harv". All of a sudden, the error message shows up in places with no such coding, and it's very distracting. I'm guessing the new coding is picking up on the "cite" template used. For instance, it now shows on most entries of bibliography articles: Bibliography of Abraham Lincoln, Bibliography of John Adams, Bibliography of Jimmy Carter, etc. etc. Whatever coding is making it do that, please correct. It's very distracting to see that all over the bibliographies. — Maile (talk) 23:04, 18 April 2020 (UTC)[reply]

@Maile66, the code hasn't changed since 2017 but what you're seeing is likely the result of CS1 now turning on the |ref=harv param by default across the site, so the script will detect every citation as now having that param (when there is no short footnote for the citation, as is the case in most bibliography articles) and throw this brown pseudo-error. Honestly, I uninstalled this script once its core functionality was built directly into CS1 (see above) so there really isn't much of a use case for most editors to keep it installed. czar 02:31, 19 April 2020 (UTC)[reply]
See #Superseded above, there's a few ways you can deal with this. You can use User:Svick/HarvErrors.js instead, or see this discussion, which mentions adding window.checkLinksToCitations = false; to your User:Maile66/common.js page. Headbomb {t · c · p · b} 02:42, 19 April 2020 (UTC)[reply]
I put a hatnote at the top of this page (copied from Help talk:Citation Style 1, written by Headbomb) to explain the changes and link to quick resolutions. Please correct it if it needs correcting. – Jonesey95 (talk) 18:14, 19 April 2020 (UTC)[reply]
Those scripts don't give us the same warnings. There is now no warning when there is a long citation but no corresponding short one, with any of these scripts, since this change. Pinging Trappist the monk, who I believe made the change. SarahSV (talk) 02:20, 22 April 2020 (UTC)[reply]
I have the Harverrors.js script installed, and it shows me the brown warning message for full citations without matching short citations, as it always has for cite templates that have ref=harv enabled. SlimVirgin, you have suppressed those messages with the last line of your User:SlimVirgin/common.js file. If you would like to show the brown warning messages, remove that last line of text. – Jonesey95 (talk) 03:59, 22 April 2020 (UTC)[reply]
Jonesey, I've explained multiple times today what the issue is. Here it is again. User:Ucucha/HarvErrors is now producing brown error messages when citations without ref=harv are used. Someone suggested window.checkLinksToCitations = false as a solution. But that script is suppressing warnings if a long citation is used as a source with ref=harv (note: as a source, not in FR), without a corresponding short citation. Without that new script, Ucucha gives us red warnings. With that new script, nothing. In other words, it is suppressing the wanted and the unwanted warnings. SarahSV (talk) 04:13, 22 April 2020 (UTC)[reply]
Jonesey, if you're not sure what I mean, I can add the script again and take screenshots with and without it. SarahSV (talk) 04:25, 22 April 2020 (UTC)[reply]
Got it. You are seeing everything working as designed, although not as you wish it would work. Just to provide a bit of technical insight, HarvErrors.js is the "script" itself, and "window.checkLinksToCitations = false" is a customization to that script so that it provides different output (specifically, no brown warning messages) for you than the script provides in its default mode.
I have had the HarvErrors.js script installed for many years, and I have learned to ignore the brown warning messages unless I am specifically looking in a Sources or Works cited section for unused sources or other mistakes. My eyes just zip right past the brown messages in sections like Further reading; they have no meaning in those sections, and regular readers do not see them, since they do not have the script installed. I treat them like ads in a magazine; I skip right past them and keep reading the stuff I came to see.
You have mentioned in other venues that when you saw those brown warning messages in the past, when the script showed the warnings for {{citation}} only, you have converted the {{citation}} templates to {{cite book}}, so it sounds like you are willing to do a little work to make the brown messages go away. I will not comment on the WP:CITEVAR implications if nobody else is objecting to that work. Happily, making the brown messages go away is easier and more consistent with WP:CITEVAR today: all you have to do is add |ref=none to each cite template in Further reading for which you want to suppress the brown message. – Jonesey95 (talk) 04:27, 22 April 2020 (UTC)[reply]
What Selected works, Further reading and Bibliographies now look like, because the absence of ref=harv makes no difference.
Re: "You are seeing everything working as designed". No, I don't think so. Why would anyone design a script to hide useful error messages? Jonesey, can you summarize the problem with the red error messages (not the brown ones) with "window.checkLinksToCitations = false", so that I know you've understood it. I'm asking because otherwise I'd prefer to explain it differently or show you. SarahSV (talk) 04:30, 22 April 2020 (UTC)[reply]
As far as I know, the window.check... modification does not affect the display of red error messages. The change to the CS1 templates has automatically fixed many thousands of red error messages, but there should not be any new problems. Please link to an article where the red error messages are behaving worse than they used to. – Jonesey95 (talk) 04:33, 22 April 2020 (UTC)[reply]

Okay, here we go again. I keep telling you it makes a difference, and you're now saying it doesn't. Test it for yourself. SarahSV (talk) 04:36, 22 April 2020 (UTC)[reply]

Thanks for the screen shot. I see those brown warning messages as well. Those have always appeared for {{citation}}, and they are newly present for {{cite book}}. I have added |ref=none to the cite templates in that section, which took about 15 seconds, and now the brown messages are gone. Putting the "window.check..." line of code in my common.js would also have suppressed them (for me only). Again, regular readers don't see them.
Test what? Please link to an article where there are red error messages that you see as somehow incorrect, or new, or otherwise undesirable. – Jonesey95 (talk) 04:39, 22 April 2020 (UTC)[reply]
I would have to install the script, remove some refs, preview, take a screenshot, then uninstall it, remove some refs, preview, take a screenshot, then upload both images. I'll do that if it will really make a difference to your understanding of this problem. SarahSV (talk) 04:45, 22 April 2020 (UTC)[reply]
It can't hurt, but from your description, the main issue here is very likely that what you are consider "a problem" is functioning exactly as intended, but not exactly as you want. To fix that discrepancy, you very likely need a new script made at WP:SCRIPTREQ, so you can have a script that functions as you want. Headbomb {t · c · p · b} 05:21, 22 April 2020 (UTC)[reply]
@Maile66: I have forked and modified the HarvErrors script so that my version does not show the brown warning messages when there are no short-cite templates ({{harv}}, {{sfn}}, etc). For me, using my script, are no warning messages in Bibliography of Abraham Lincoln, Bibliography of John Adams, or Bibliography of Jimmy Carter. To try my version of this script, in User:Maile66/common.js, add:
importScript('User:Trappist the monk/HarvErrors.js');
My color scheme is a bit different, errors are dark orange and messages are written at normal font size.
——Trappist the monk (talk) 10:55, 22 April 2020 (UTC)[reply]
I have installed it, and it works. Thanks. — Maile (talk) 11:15, 22 April 2020 (UTC)[reply]
Someone should make a summary of the differences of each scripts that's been made so far. We have four now, the original from Svick, Ucucha's, David Eppstein's, and now Trappist the monk's. Headbomb {t · c · p · b} 12:16, 22 April 2020 (UTC)[reply]