From Wikipedia, the free encyclopedia

Differences with original script

This script is a tweaked copy of User:Ucucha/HarvErrors.js ( compare the two).

Differences:

  • messages rendered by this script are normal font size
  • error messages have different coloring to distinguish them from CS1/ CS2 error messages, and harv/sfn error messages:
    • no-target and target-in-wrong-section errors are DarkOrange
    • multiple-target errors are some-sort-of purple
  • when the article does not have CITEREF anchor IDs, does not emit warning messages
  • when the article has CITEREF anchor IDs:
    • does not emit warning messages for citations in §§Further reading and External links
    • will emit an error message when a citations in §§Further reading and External links have matching links
    • caveat lector: §§Further reading and External links must be a level 2 sections; spelling and capitalization as shown here:
      • ==Further reading==
      • ==External links==
Content above by Trappist the monk; moved here by Mathglot ( talk) 04:11, 23 August 2023 (UTC). reply

Disable warnings on talk page?

@ Trappist the monk: Having the red errors messages is usually fine on talk pages (although of limited value), but the brown warnings are rather pointless there. No idea if the red errors should be disabled on (all) talk pages, but the brown warnings definitely should. Headbomb { t · c · p · b} 14:24, 7 July 2020 (UTC) reply

False positive

@ Trappist the monk: False positive with {{ Cite DCB}} e.g. Alexander_Mackenzie_(politician)#cite_note-FOOTNOTEForster1990-2 –  Finnusertop ( talkcontribs) 21:41, 15 July 2020 (UTC) reply

It is a false positive for Module:Footnotes; it is not a false positive for User:Trappist the monk/HarvErrors.js. This talk page is not the correct place to report these kinds of errors. A better place is Module talk:Footnotes.
Trappist the monk ( talk) 21:59, 15 July 2020 (UTC) reply
Will do. –  Finnusertop ( talkcontribs) 22:29, 15 July 2020 (UTC) reply

importScript is deprecated

@ Trappist the monk, @ Headbomb: Per mw:ResourceLoader/Migration guide (users)#importScript, importScript is deprecated since MediaWiki 1.29 and does not work on mobile view. The install instruction should be changed such that it uses mw.loader.load instead. ネイ ( talk) 13:49, 2 October 2021 (UTC) reply

If this is so, it's very likely that a bot should take care of the conversions across all scripts. Headbomb { t · c · p · b} 14:16, 2 October 2021 (UTC) reply

Citation bundles

Not sure anything should be done about this, but have a look at the at note 1 at Transgender#Notes. The individual bullets are not cited in the body, because they are part of the WP:CITEBUNDLE listed in the <ref group="note"> in section § Transgender. As part of the bundle, they're unaddressable as individual citations and thus no need to flag them. On the other hand, if it would require a lot of squirrelly parsing and/or explode the test cases, then it may be better just to ignore the false positives in this case, if there's a risk of making the script more fragile in other cases. Thanks for this script, I just added it, and it looks really useful. Mathglot ( talk) 22:37, 28 June 2023 (UTC) reply

If there are no links to those references, and you are bothered by the Harv warning: There is no link pointing to this citation. The anchor is named CITEREF... message, set |ref=none in the cs1|2 templates.
As part of the bundle, they're unaddressable as individual citations What does that mean? Certainly they are 'addressable':
[[Transgender#CITEREFOliven1974]]Transgender#CITEREFOliven1974
setting |ref=none will make them unaddressable
It is likely that they shouldn't be addressed with {{ sfn}} or {{ harvnb}} but that doesn't mean that they can't be. Also, for those references, linking to archived snapshots of the google books landing page seems to me to be sort of pointless...
Trappist the monk ( talk) 23:38, 28 June 2023 (UTC) reply

Suggestion: demote "linked from id" to warning message

I'd like to propose that one of the error messages be downgraded to "warning", because failing to fix it does not violate any Wikipedia policy or hurt Verifiability or the article in any way, or at least, no more seriously than a layout violation. Currently, "Harv error: linked from 'X' " is listed as an error, but really, imho it should only be a warning. Here's why:

Of all the four messages generated, only #1 ("link from 'X' doesn't point to any citation") and #2 ("'X' has multiple targets") if left unrepaired, impact the verifiability of the article. WP:Verifiability is policy, and if left unchanged, other editors would be justified by policy in removing article content preceding those error messages based on lack of sourcing. WP:BURDEN says, "Any material lacking an inline citation to a reliable source that directly supports[ 2 the material may be removed and should not be restored without an inline citation to a reliable source."

However, this is not the case for the other two messages. The message "Harv error: linked from 'X'" represents a citation with an incoming link from some sfn being located under the wrong section header, perhaps under "Further reading" where it should be under "Bibliography". This isn't a serious error, the article bearing this message still supports verifiability, violates no other policy, and would not justify any content removal by another editor, even if it is never fixed. At worst, this is similar to a guideline violation of MOS:LAYOUT where stuff is not located in the right place, such as an external link being placed in the "See also" section. It's kind of the half-sister of the unused citation warning, which is really just another case of something being in the wrong place, only this time, it's the other way round: there's a full citation which isn't the target of a short footnote which was placed in section "Bibliography", whereas it should have been in "Further reading". Here once again, even if this is never fixed, it's at worst a LAYOUT violation, but Verifiability is not impacted. Both "wrong section" messages should be warnings, not just the one that is now. Mathglot ( talk) 00:26, 20 August 2023 (UTC) reply

Color style cannot be overridden in common.css

 Courtesy link:  Wikipedia:User scripts/Requests § external css for a user script?

As far as I can tell, the defined color style of the error and warning messages in the script cannot be overridden because of the way it's coded in the script with the color-setting span "style" attribute coming last. In particular, the "ttm_harv_err" elements will always have the DarkOrange color, regardless of what the user might do in their common.css. Example (line 27; sample citeref substituted in for clarity):

  • <span class="ttm_harv_err" style="color:DarkOrange">Harv error: link from "CITEREFSmith2023" doesn't point to any citation.</span>

You can override other attributes, for example, adding this to common.css will shade the message with background color:

  • .ttm_harv_err {color:black; background-color:cornsilk}

but the font remains dark orange (not black) because of the order of priority of css style, with the inline css in the "style" attribute highest priority. I'm unaware of any method of overriding inline style defined right in the <span> tag. But I think you can still get the default dark orange font that you want, and have overridable color via a user's common.css by using two classes, one of which you define, and the other which you don't, and put after the predefined one, something like this:

  • <span class="ttm_harv_err_default ttm_harv_err">Harv error: link from "CITEREFSmith2023" doesn't point to any citation.</span>

and include a <style> block on the page where you'd define your defaults:

  • <style>.ttm_harv_err_default { color:DarkOrange }</style> # you can include the other defaults in here at the same time

The problem is, I'm better at css than I am at javascript, and I don't know if it's actually possible to implement this proposal using scripting. And secondly, in the template world, there's something called TemplateStyles.css, which fits somewhere into priority sequence, and maybe there's something analogous like ScriptingStyles.js, but if there is, I don't know about it. But I know who would: Izno; if you don't mind, could you look over my analysis to see if it makes sense, and if the proposed solution is viable, or if there's perhaps a better way to do it? Thanks, Mathglot ( talk) 20:48, 20 August 2023 (UTC) reply

Changing the script to use the existing class for styling would be preferable (you don't even need _default I don't think, but someone would need to review). I don't know exactly how to do this. :)
That said, when there are inline styles which you want to customize, as long as you have a class to target, you may use !important (without having to deal with too many of the reasons why you shouldn't generally). In this case, .ttm_harv_err {color:black !important; background-color:cornsilk} would suffice to make the color black. Izno ( talk) 21:24, 20 August 2023 (UTC) reply
Cool, thanks! I believe that one issue is that the ttm_harv_err class doesn't exist, leaving the user to define it for the first time; so, if I understand your first sentence correctly, we don't need two classes (i.e., we don't need the added *_default class) and just define the existing class as DarkOrange, remove the inline style on the span tag, and let the user override the color using the ttm_harv_err class in common.css. That does seem like a more economical way of doing it. But the !important trick seems really useful, and I'll study up a bit to see what any concomitant "dont-use-it" issues might be. Thanks again, Mathglot ( talk) 21:32, 20 August 2023 (UTC) reply

Trappist, does this make sense, as far as removing the "style" attributes inline, and default the color via the class at the outset, if possible? That seems more straightforward for users, so that we don't force them to override via !important. Mathglot ( talk) 22:16, 20 August 2023 (UTC) reply

Editor Izno's suggestion works. I don't know how to create a set of standard (default) classes external to HarvErrors.js. I suppose that in Candide's best-of-all-possible-worlds, we would create a TemplateStyles .css page to style Module:Footnotes messaging but also the messaging for HarvErrors.js. Somewhere around here there must be someone who knows if that is possible. I'll look around.
Trappist the monk ( talk) 23:10, 20 August 2023 (UTC) reply
Asked at Wikipedia:User scripts/Requests § external css for a user script?
Trappist the monk ( talk) 23:22, 20 August 2023 (UTC) reply
Thanks, subscribed. Mathglot ( talk) 23:28, 20 August 2023 (UTC) reply
Actually, I wasn't thinking of classes external to HarvErrors.js, but if I understand correctly, js can insert code onto the page, so that it should be able to create a <style> block on the page, most likely right before the ending </head> tag, and place the default class definition for .ttm_harv_err_default (and the other ones) inside that block, and not on some other page. Mathglot ( talk) 23:48, 20 August 2023 (UTC) reply

If I understand correctly from the discussion at Wikipedia:User scripts/Requests#external css for a user script?, this issue has now been resolved, which is great news, and makes it possible to fill out section § Style customization and provide guidance to users who wish to customize the colors and other style attributes of the error and warning messages, so I've updated that section. It's been a real education here, and at that discussion, and I wanted to thank you for your contributions in both, your efforts to resolve this, and indeed for your maintenance and improvement of this highly useful script that I feel is getting justifiably adopted more and more. Thanks again. Mathglot ( talk) 05:20, 22 August 2023 (UTC) reply

Edit request: please exclude "Publications" section

The ==Publications== section appears to be used for listing works by authors, such as in these articles:

I think replacing line 49 as follows should do it:

  var sections = [further_reading, external_links]; // make an array of links in these sections
+
  var publications = content.find('#Publications').parent().nextUntil('h2').find('.citation').get(); // get all cites inside a Publications section var sections = [further_reading, external_links, publications]; // make an array of links in these sections

Thanks, Mathglot ( talk) 03:36, 5 October 2023 (UTC) reply

Done, but I'm not sure that it does what you want. It does not suppress the 'There is no link pointing to this citation' message but will emit the 'linked from' error message.
Trappist the monk ( talk) 19:31, 5 October 2023 (UTC) reply
It's looking exactly like it did before, even after I purged everything and tried another browser, and I don't understand why. (Ignoring 'Novak', which was a bad example, because it's in an H3, not an H2; but the others are all H2.) Is it working for you? Mathglot ( talk) 20:32, 5 October 2023 (UTC) reply
When I looked at Knuth before the change, I saw a lot of Harv warning: There is no link pointing to this citation. The anchor is named CITEREFKnuthXXXX messages. Those are the messages that I still see. At Knuth, I added {{ harvnb|Knuth|1997}} above Donald Knuth § Publications. When I preview the article, I see Harv error: linked from CITEREFKnuth1997 and Harv error: duplicate target for CITEREFKnuth1997 messages for the first two templates under The Art of Computer Programming. These are, I think, the results to be expected.
Trappist the monk ( talk) 22:21, 5 October 2023 (UTC) reply
At Knuth, I see 29 "Harv warning: There is no link pointing to this citation. The anchor is named CITEREFKnuth2015", namely: 1–13 at Art of Computer Programming; 1–8 at Computers and Typesetting; 1–6 at Books of collected papers and 1–2 at Other books. (But not 3–12 at Other books.) I don't get Harv error warnings from the Module; I've shut them off because your script is more accurate, and I don't need to see them twice. What I don't understeand, though, is that with the new code detecting the "Publications" links (if it's in an H2, like at Knuth) and adding them to the 'sections' array, shouldn't they all be suppressed from inclusion of the brown, "no link" message? That's what happens if they're in "External links" or "Further reading", right, so why should it be different here? Mathglot ( talk) 22:41, 5 October 2023 (UTC) reply
Line 54 I think fixes it.
Trappist the monk ( talk) 23:10, 5 October 2023 (UTC) reply
Oh, my gosh: how did I miss that?! Thanks! Mathglot ( talk) 23:50, 5 October 2023 (UTC) reply

Getting ttm_harv_warn on citec templates, even when sfn-whitelisted

I am getting ttm_harv_err ("no link pointing to...") when wrapping a section of a page containing a cite_book and two citec's with template Reflib, even with {{ sfn whitelist}} in effect. To reproduce, place the following code on Special:ExpandTemplates or other test page:

{{reflib|lib=Asea|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

This wraps a section containing a {{ cite book}} template, and two {{ citec}} templates linked to it. Even with the follow-up sfn whitelist, two ttm_harv_err's are emitted anyway.

Reflib is working to spec, but if you suspect something fishy with it, or just want to eliminate one extra possible source of error, you can generate the identical output without Reflib, using selective transclusion, this way:

{{#section-h:Template:Reflib/Ancient seafaring|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

I poked around a bit in the code, but not sure what's going on. One thing I noticed: if you look at the ExpandTemplates output, whereas the main, cite_book template generates a <cite id="CITEREFCatsambisFordHamilton2011"...>, the two citec templates do not—they generate a <span id=...> instead, so I wonder if that's a clue.

ExpandTemplates output
Showing the result of the following
{{reflib|lib=Asea|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

Generates the following result html in ExpandTemplates (extra line breaks added, to make code-reading easier):

*<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>

<cite id="CITEREFCatsambisFordHamilton2011" class="citation book cs1">Catsambis, Alexis; Ford, Ben; Hamilton, Donny L., eds. (2011). ''The Oxford Handbook of Maritime Archaeology''. OUP. [[ISBN (identifier)|ISBN]] [[Special:BookSources/978-0-19-537517-6|<bdi>978-0-19-537517-6</bdi>]]. [[OCLC (identifier)|OCLC]] [https://www.worldcat.org/oclc/639940479 639940479].</cite>
<span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Oxford+Handbook+of+Maritime+Archaeology&rft.pub=OUP&rft.date=2011&rft_id=info%3Aoclcnum%2F639940479&rft.isbn=978-0-19-537517-6&rfr_id=info%3Asid%2Fen.wikipedia.org%3AShips+of+ancient+Rome" class="Z3988"></span>

* <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles><span id="CITEREFCarlson2011" class="citation">Carlson, Deborah N. "[https://books.google.com/books?id=GOESDAAAQBAJ&pg=PA379 17. The Seafarers and Shipwrecks of Ancient Greece and Rome]". In [[#CITEREFCatsambisFordHamilton2011|Catsambis, Ford & Hamilton (2011)]], pp. 379–405.</span>

* <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles><span id="CITEREFDelgado2011" class="citation">Delgado, James P. "Ships on Land". In [[#CITEREFCatsambisFordHamilton2011|Catsambis, Ford & Hamilton (2011)]], pp. 182–191.</span><br />

If you want to see the real-world occurrence that sparked this stripped down example, see Ships of ancient Rome#Works cited. Thanks, Mathglot ( talk) 06:52, 23 October 2023 (UTC) reply

I've just cleared a couple of errors on the page, but they seem unrelated to this one.
I only have the base messages turn on in common.css and I don't see any error messages for Carlson or Delgado. Is this an issue with HarvErrors.js? -- LCU ActivelyDisinterested transmissions ° co-ords° 09:11, 23 October 2023 (UTC) reply
AD, thanks. That's what I'm trying to figure out, whether it's something with the script, or maybe with Module:Footnotes? I see five warnings there now: Delgado, Dotson, Morrison, Pryor, Wachsmann; you don't see those? Try search-on-page (Ctrl+F) for 'no link pointing', and it should give you a count, or highlight them, depending on your browser. How many do you see? Mathglot ( talk) 16:39, 23 October 2023 (UTC) reply
Ok I see whats going on now. The script adds a message for all cites that are not used by referencing. This isn't an error message, but extra functionality that the script adds.
The message is just telling you that those cites aren't in use. It's there to help clean up articles, as cites that aren't in use should be in 'Further reading' rather than 'Works cited'. -- LCU ActivelyDisinterested transmissions ° co-ords° 16:45, 23 October 2023 (UTC) reply
Yeah, that ↑. Delgado, Dotson, Morrison, Pryor, Wachsmann are listed in §Works cited but those sources are not cited in the body of the article. Use them or move them to §Further reading or delete them as unnecessary clutter.
Trappist the monk ( talk) 17:03, 23 October 2023 (UTC) reply
Yes, that's correct, they are in Works_cited, and not used in the body, because they are chapters of a book that is used in the body, as are other chapters of the same book. The question is, as the CITEREFS for those unused chapters are already listed in {{ sfn whitelist}}, so why doesn't that suppress those warning messages? Alternatively, I suppose I could code a zero-width link, such as [[#CITEREFDelgado2011|{{zwsp}}]] as a honeypot for the script to find and skip the warning, but I thought sfn_whitelist would deal with that. As far as moving them to Further_reading, imho it makes more sense to keep chapters of the same book cited via citec/harvc close to the books they are chapters of. There isn't enough usage of citec/harvc to have a consensus of where people want their book chapters to appear, but I like keeping book chapters of the same book together, not in separate sections of the article, just because some of the chapters are not (yet) cited. Mathglot ( talk) 19:19, 23 October 2023 (UTC) reply
{{ sfn whitelist}} is for Module:Footnotes-generated errors; it has no meaning to HarvErrors.js. HarvErrors.js will never recognize {{sfn whitelist}} because that template does not create output that is visible in the article's html (where HarvErrors.js operates).
If Delgado and the others are not cited in the body of the article, they are cruft that should be removed. I agree that (when used) {{ harvc}} templates should be near the cs1|2 template ( Template:Harvc § Basic example illustrates my preferred style). Not used, hide or remove.
Trappist the monk ( talk) 19:41, 23 October 2023 (UTC) reply
 Resolved. Thanks, resolved using {{ cite whitelink}}, which I created a few months ago for this type of situation, and then promptly forgot about. Mathglot ( talk) 03:37, 24 October 2023 (UTC) reply

Unexpected "no-links" warnings

I'm seeing unexpected "no-links" warnings at Collaborationism in France during the Second World War in section "#Reviews", which isn't one of the sections I thought it emitted warnings for. Mathglot ( talk) 11:39, 22 November 2023 (UTC) reply

Are you sure? The script suppresses some messaging for citations found in §Further reading, §External links, and §Publications; all other sections will show messaging.
Rename Collaborationism in France during the Second World War § Reviews to Collaborationism in France during the Second World War § Publications and preview – it will show that the Peyre and Watson citations are probably in the wrong place and the warning messages will be suppressed.
Trappist the monk ( talk) 00:07, 23 November 2023 (UTC) reply

Warnings incorrectly show in multiref(2) if author mentioned and Sfn used on page

I often use Template:Multiref2 to bundle sources. I have noticed that some of the bundled citations incorrectly display Harv warnings. I was able to narrow it down.

If the page uses Sfn (or harv) citations anywhere on the page, then a multiref-bundled cite-web citation with a name parameter (|author= or |last=) will incorrectly display the error. The harv warning is NOT displayed for bundled citations that do NOT use names. The warning doesn't display if I unbundle the citations (ref them separately instead of putting them in a multiref container). And the harv warning is NOT displayed if Sfn or Harv are never once used on the page.

I made a sample page to show the behavior: User:Grorp/sandbox4

It is written like a bug report, with instructions for an interaction. You can edit the page and remove the one instance using Sfn and you'll see the anomaly disappear.

It doesn't make sense that the same citation which doesn't generate a warning, does show a warning if bundled into multiref or multiref2.   ▶ I am Grorp ◀ 01:04, 23 January 2024 (UTC) reply

Working as it is intended to work.
cs1|2 templates create CITEREF id attributes for each citation's enclosing <cite>...</cite> tag only when there is an author, contributor, or editor name.
When there are no {{ sfn}} or {{harv}}-family templates in a page, HarvErrors does not check for errors and so does not emit error and warning messages.
When the page has {{sfn}} or {{harv}}-family templates, HarvErrors emits the no-link-pointing-to-this-citation warning message when a cs1|2 citation has a CITEREF id and when the citation is not inside its own <ref>...</ref> tags or is not in §Further reading, §External links, or §Publications sections.
You are seeing the warnings because the two citations inside {{ multiref2}} have author names (CITEREF ids) but are not wrapped inside their own <ref>...</ref> tags (and are outside of any §Further reading, §External links, and §Publications sections).
You can suppress the warning message by adding |ref=none to the two cs1|2 templates with author names.
Trappist the monk ( talk) 14:50, 23 January 2024 (UTC) reply
From Wikipedia, the free encyclopedia

Differences with original script

This script is a tweaked copy of User:Ucucha/HarvErrors.js ( compare the two).

Differences:

  • messages rendered by this script are normal font size
  • error messages have different coloring to distinguish them from CS1/ CS2 error messages, and harv/sfn error messages:
    • no-target and target-in-wrong-section errors are DarkOrange
    • multiple-target errors are some-sort-of purple
  • when the article does not have CITEREF anchor IDs, does not emit warning messages
  • when the article has CITEREF anchor IDs:
    • does not emit warning messages for citations in §§Further reading and External links
    • will emit an error message when a citations in §§Further reading and External links have matching links
    • caveat lector: §§Further reading and External links must be a level 2 sections; spelling and capitalization as shown here:
      • ==Further reading==
      • ==External links==
Content above by Trappist the monk; moved here by Mathglot ( talk) 04:11, 23 August 2023 (UTC). reply

Disable warnings on talk page?

@ Trappist the monk: Having the red errors messages is usually fine on talk pages (although of limited value), but the brown warnings are rather pointless there. No idea if the red errors should be disabled on (all) talk pages, but the brown warnings definitely should. Headbomb { t · c · p · b} 14:24, 7 July 2020 (UTC) reply

False positive

@ Trappist the monk: False positive with {{ Cite DCB}} e.g. Alexander_Mackenzie_(politician)#cite_note-FOOTNOTEForster1990-2 –  Finnusertop ( talkcontribs) 21:41, 15 July 2020 (UTC) reply

It is a false positive for Module:Footnotes; it is not a false positive for User:Trappist the monk/HarvErrors.js. This talk page is not the correct place to report these kinds of errors. A better place is Module talk:Footnotes.
Trappist the monk ( talk) 21:59, 15 July 2020 (UTC) reply
Will do. –  Finnusertop ( talkcontribs) 22:29, 15 July 2020 (UTC) reply

importScript is deprecated

@ Trappist the monk, @ Headbomb: Per mw:ResourceLoader/Migration guide (users)#importScript, importScript is deprecated since MediaWiki 1.29 and does not work on mobile view. The install instruction should be changed such that it uses mw.loader.load instead. ネイ ( talk) 13:49, 2 October 2021 (UTC) reply

If this is so, it's very likely that a bot should take care of the conversions across all scripts. Headbomb { t · c · p · b} 14:16, 2 October 2021 (UTC) reply

Citation bundles

Not sure anything should be done about this, but have a look at the at note 1 at Transgender#Notes. The individual bullets are not cited in the body, because they are part of the WP:CITEBUNDLE listed in the <ref group="note"> in section § Transgender. As part of the bundle, they're unaddressable as individual citations and thus no need to flag them. On the other hand, if it would require a lot of squirrelly parsing and/or explode the test cases, then it may be better just to ignore the false positives in this case, if there's a risk of making the script more fragile in other cases. Thanks for this script, I just added it, and it looks really useful. Mathglot ( talk) 22:37, 28 June 2023 (UTC) reply

If there are no links to those references, and you are bothered by the Harv warning: There is no link pointing to this citation. The anchor is named CITEREF... message, set |ref=none in the cs1|2 templates.
As part of the bundle, they're unaddressable as individual citations What does that mean? Certainly they are 'addressable':
[[Transgender#CITEREFOliven1974]]Transgender#CITEREFOliven1974
setting |ref=none will make them unaddressable
It is likely that they shouldn't be addressed with {{ sfn}} or {{ harvnb}} but that doesn't mean that they can't be. Also, for those references, linking to archived snapshots of the google books landing page seems to me to be sort of pointless...
Trappist the monk ( talk) 23:38, 28 June 2023 (UTC) reply

Suggestion: demote "linked from id" to warning message

I'd like to propose that one of the error messages be downgraded to "warning", because failing to fix it does not violate any Wikipedia policy or hurt Verifiability or the article in any way, or at least, no more seriously than a layout violation. Currently, "Harv error: linked from 'X' " is listed as an error, but really, imho it should only be a warning. Here's why:

Of all the four messages generated, only #1 ("link from 'X' doesn't point to any citation") and #2 ("'X' has multiple targets") if left unrepaired, impact the verifiability of the article. WP:Verifiability is policy, and if left unchanged, other editors would be justified by policy in removing article content preceding those error messages based on lack of sourcing. WP:BURDEN says, "Any material lacking an inline citation to a reliable source that directly supports[ 2 the material may be removed and should not be restored without an inline citation to a reliable source."

However, this is not the case for the other two messages. The message "Harv error: linked from 'X'" represents a citation with an incoming link from some sfn being located under the wrong section header, perhaps under "Further reading" where it should be under "Bibliography". This isn't a serious error, the article bearing this message still supports verifiability, violates no other policy, and would not justify any content removal by another editor, even if it is never fixed. At worst, this is similar to a guideline violation of MOS:LAYOUT where stuff is not located in the right place, such as an external link being placed in the "See also" section. It's kind of the half-sister of the unused citation warning, which is really just another case of something being in the wrong place, only this time, it's the other way round: there's a full citation which isn't the target of a short footnote which was placed in section "Bibliography", whereas it should have been in "Further reading". Here once again, even if this is never fixed, it's at worst a LAYOUT violation, but Verifiability is not impacted. Both "wrong section" messages should be warnings, not just the one that is now. Mathglot ( talk) 00:26, 20 August 2023 (UTC) reply

Color style cannot be overridden in common.css

 Courtesy link:  Wikipedia:User scripts/Requests § external css for a user script?

As far as I can tell, the defined color style of the error and warning messages in the script cannot be overridden because of the way it's coded in the script with the color-setting span "style" attribute coming last. In particular, the "ttm_harv_err" elements will always have the DarkOrange color, regardless of what the user might do in their common.css. Example (line 27; sample citeref substituted in for clarity):

  • <span class="ttm_harv_err" style="color:DarkOrange">Harv error: link from "CITEREFSmith2023" doesn't point to any citation.</span>

You can override other attributes, for example, adding this to common.css will shade the message with background color:

  • .ttm_harv_err {color:black; background-color:cornsilk}

but the font remains dark orange (not black) because of the order of priority of css style, with the inline css in the "style" attribute highest priority. I'm unaware of any method of overriding inline style defined right in the <span> tag. But I think you can still get the default dark orange font that you want, and have overridable color via a user's common.css by using two classes, one of which you define, and the other which you don't, and put after the predefined one, something like this:

  • <span class="ttm_harv_err_default ttm_harv_err">Harv error: link from "CITEREFSmith2023" doesn't point to any citation.</span>

and include a <style> block on the page where you'd define your defaults:

  • <style>.ttm_harv_err_default { color:DarkOrange }</style> # you can include the other defaults in here at the same time

The problem is, I'm better at css than I am at javascript, and I don't know if it's actually possible to implement this proposal using scripting. And secondly, in the template world, there's something called TemplateStyles.css, which fits somewhere into priority sequence, and maybe there's something analogous like ScriptingStyles.js, but if there is, I don't know about it. But I know who would: Izno; if you don't mind, could you look over my analysis to see if it makes sense, and if the proposed solution is viable, or if there's perhaps a better way to do it? Thanks, Mathglot ( talk) 20:48, 20 August 2023 (UTC) reply

Changing the script to use the existing class for styling would be preferable (you don't even need _default I don't think, but someone would need to review). I don't know exactly how to do this. :)
That said, when there are inline styles which you want to customize, as long as you have a class to target, you may use !important (without having to deal with too many of the reasons why you shouldn't generally). In this case, .ttm_harv_err {color:black !important; background-color:cornsilk} would suffice to make the color black. Izno ( talk) 21:24, 20 August 2023 (UTC) reply
Cool, thanks! I believe that one issue is that the ttm_harv_err class doesn't exist, leaving the user to define it for the first time; so, if I understand your first sentence correctly, we don't need two classes (i.e., we don't need the added *_default class) and just define the existing class as DarkOrange, remove the inline style on the span tag, and let the user override the color using the ttm_harv_err class in common.css. That does seem like a more economical way of doing it. But the !important trick seems really useful, and I'll study up a bit to see what any concomitant "dont-use-it" issues might be. Thanks again, Mathglot ( talk) 21:32, 20 August 2023 (UTC) reply

Trappist, does this make sense, as far as removing the "style" attributes inline, and default the color via the class at the outset, if possible? That seems more straightforward for users, so that we don't force them to override via !important. Mathglot ( talk) 22:16, 20 August 2023 (UTC) reply

Editor Izno's suggestion works. I don't know how to create a set of standard (default) classes external to HarvErrors.js. I suppose that in Candide's best-of-all-possible-worlds, we would create a TemplateStyles .css page to style Module:Footnotes messaging but also the messaging for HarvErrors.js. Somewhere around here there must be someone who knows if that is possible. I'll look around.
Trappist the monk ( talk) 23:10, 20 August 2023 (UTC) reply
Asked at Wikipedia:User scripts/Requests § external css for a user script?
Trappist the monk ( talk) 23:22, 20 August 2023 (UTC) reply
Thanks, subscribed. Mathglot ( talk) 23:28, 20 August 2023 (UTC) reply
Actually, I wasn't thinking of classes external to HarvErrors.js, but if I understand correctly, js can insert code onto the page, so that it should be able to create a <style> block on the page, most likely right before the ending </head> tag, and place the default class definition for .ttm_harv_err_default (and the other ones) inside that block, and not on some other page. Mathglot ( talk) 23:48, 20 August 2023 (UTC) reply

If I understand correctly from the discussion at Wikipedia:User scripts/Requests#external css for a user script?, this issue has now been resolved, which is great news, and makes it possible to fill out section § Style customization and provide guidance to users who wish to customize the colors and other style attributes of the error and warning messages, so I've updated that section. It's been a real education here, and at that discussion, and I wanted to thank you for your contributions in both, your efforts to resolve this, and indeed for your maintenance and improvement of this highly useful script that I feel is getting justifiably adopted more and more. Thanks again. Mathglot ( talk) 05:20, 22 August 2023 (UTC) reply

Edit request: please exclude "Publications" section

The ==Publications== section appears to be used for listing works by authors, such as in these articles:

I think replacing line 49 as follows should do it:

  var sections = [further_reading, external_links]; // make an array of links in these sections
+
  var publications = content.find('#Publications').parent().nextUntil('h2').find('.citation').get(); // get all cites inside a Publications section var sections = [further_reading, external_links, publications]; // make an array of links in these sections

Thanks, Mathglot ( talk) 03:36, 5 October 2023 (UTC) reply

Done, but I'm not sure that it does what you want. It does not suppress the 'There is no link pointing to this citation' message but will emit the 'linked from' error message.
Trappist the monk ( talk) 19:31, 5 October 2023 (UTC) reply
It's looking exactly like it did before, even after I purged everything and tried another browser, and I don't understand why. (Ignoring 'Novak', which was a bad example, because it's in an H3, not an H2; but the others are all H2.) Is it working for you? Mathglot ( talk) 20:32, 5 October 2023 (UTC) reply
When I looked at Knuth before the change, I saw a lot of Harv warning: There is no link pointing to this citation. The anchor is named CITEREFKnuthXXXX messages. Those are the messages that I still see. At Knuth, I added {{ harvnb|Knuth|1997}} above Donald Knuth § Publications. When I preview the article, I see Harv error: linked from CITEREFKnuth1997 and Harv error: duplicate target for CITEREFKnuth1997 messages for the first two templates under The Art of Computer Programming. These are, I think, the results to be expected.
Trappist the monk ( talk) 22:21, 5 October 2023 (UTC) reply
At Knuth, I see 29 "Harv warning: There is no link pointing to this citation. The anchor is named CITEREFKnuth2015", namely: 1–13 at Art of Computer Programming; 1–8 at Computers and Typesetting; 1–6 at Books of collected papers and 1–2 at Other books. (But not 3–12 at Other books.) I don't get Harv error warnings from the Module; I've shut them off because your script is more accurate, and I don't need to see them twice. What I don't understeand, though, is that with the new code detecting the "Publications" links (if it's in an H2, like at Knuth) and adding them to the 'sections' array, shouldn't they all be suppressed from inclusion of the brown, "no link" message? That's what happens if they're in "External links" or "Further reading", right, so why should it be different here? Mathglot ( talk) 22:41, 5 October 2023 (UTC) reply
Line 54 I think fixes it.
Trappist the monk ( talk) 23:10, 5 October 2023 (UTC) reply
Oh, my gosh: how did I miss that?! Thanks! Mathglot ( talk) 23:50, 5 October 2023 (UTC) reply

Getting ttm_harv_warn on citec templates, even when sfn-whitelisted

I am getting ttm_harv_err ("no link pointing to...") when wrapping a section of a page containing a cite_book and two citec's with template Reflib, even with {{ sfn whitelist}} in effect. To reproduce, place the following code on Special:ExpandTemplates or other test page:

{{reflib|lib=Asea|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

This wraps a section containing a {{ cite book}} template, and two {{ citec}} templates linked to it. Even with the follow-up sfn whitelist, two ttm_harv_err's are emitted anyway.

Reflib is working to spec, but if you suspect something fishy with it, or just want to eliminate one extra possible source of error, you can generate the identical output without Reflib, using selective transclusion, this way:

{{#section-h:Template:Reflib/Ancient seafaring|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

I poked around a bit in the code, but not sure what's going on. One thing I noticed: if you look at the ExpandTemplates output, whereas the main, cite_book template generates a <cite id="CITEREFCatsambisFordHamilton2011"...>, the two citec templates do not—they generate a <span id=...> instead, so I wonder if that's a clue.

ExpandTemplates output
Showing the result of the following
{{reflib|lib=Asea|Catsambis-2011}}
{{sfn whitelist|CITEREFCarlson2011|CITEREFDelgado2011}}

Generates the following result html in ExpandTemplates (extra line breaks added, to make code-reading easier):

*<templatestyles src="Module:Citation/CS1/styles.css"></templatestyles>

<cite id="CITEREFCatsambisFordHamilton2011" class="citation book cs1">Catsambis, Alexis; Ford, Ben; Hamilton, Donny L., eds. (2011). ''The Oxford Handbook of Maritime Archaeology''. OUP. [[ISBN (identifier)|ISBN]] [[Special:BookSources/978-0-19-537517-6|<bdi>978-0-19-537517-6</bdi>]]. [[OCLC (identifier)|OCLC]] [https://www.worldcat.org/oclc/639940479 639940479].</cite>
<span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=The+Oxford+Handbook+of+Maritime+Archaeology&rft.pub=OUP&rft.date=2011&rft_id=info%3Aoclcnum%2F639940479&rft.isbn=978-0-19-537517-6&rfr_id=info%3Asid%2Fen.wikipedia.org%3AShips+of+ancient+Rome" class="Z3988"></span>

* <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles><span id="CITEREFCarlson2011" class="citation">Carlson, Deborah N. "[https://books.google.com/books?id=GOESDAAAQBAJ&pg=PA379 17. The Seafarers and Shipwrecks of Ancient Greece and Rome]". In [[#CITEREFCatsambisFordHamilton2011|Catsambis, Ford & Hamilton (2011)]], pp. 379–405.</span>

* <templatestyles src="Module:Citation/CS1/styles.css"></templatestyles><span id="CITEREFDelgado2011" class="citation">Delgado, James P. "Ships on Land". In [[#CITEREFCatsambisFordHamilton2011|Catsambis, Ford & Hamilton (2011)]], pp. 182–191.</span><br />

If you want to see the real-world occurrence that sparked this stripped down example, see Ships of ancient Rome#Works cited. Thanks, Mathglot ( talk) 06:52, 23 October 2023 (UTC) reply

I've just cleared a couple of errors on the page, but they seem unrelated to this one.
I only have the base messages turn on in common.css and I don't see any error messages for Carlson or Delgado. Is this an issue with HarvErrors.js? -- LCU ActivelyDisinterested transmissions ° co-ords° 09:11, 23 October 2023 (UTC) reply
AD, thanks. That's what I'm trying to figure out, whether it's something with the script, or maybe with Module:Footnotes? I see five warnings there now: Delgado, Dotson, Morrison, Pryor, Wachsmann; you don't see those? Try search-on-page (Ctrl+F) for 'no link pointing', and it should give you a count, or highlight them, depending on your browser. How many do you see? Mathglot ( talk) 16:39, 23 October 2023 (UTC) reply
Ok I see whats going on now. The script adds a message for all cites that are not used by referencing. This isn't an error message, but extra functionality that the script adds.
The message is just telling you that those cites aren't in use. It's there to help clean up articles, as cites that aren't in use should be in 'Further reading' rather than 'Works cited'. -- LCU ActivelyDisinterested transmissions ° co-ords° 16:45, 23 October 2023 (UTC) reply
Yeah, that ↑. Delgado, Dotson, Morrison, Pryor, Wachsmann are listed in §Works cited but those sources are not cited in the body of the article. Use them or move them to §Further reading or delete them as unnecessary clutter.
Trappist the monk ( talk) 17:03, 23 October 2023 (UTC) reply
Yes, that's correct, they are in Works_cited, and not used in the body, because they are chapters of a book that is used in the body, as are other chapters of the same book. The question is, as the CITEREFS for those unused chapters are already listed in {{ sfn whitelist}}, so why doesn't that suppress those warning messages? Alternatively, I suppose I could code a zero-width link, such as [[#CITEREFDelgado2011|{{zwsp}}]] as a honeypot for the script to find and skip the warning, but I thought sfn_whitelist would deal with that. As far as moving them to Further_reading, imho it makes more sense to keep chapters of the same book cited via citec/harvc close to the books they are chapters of. There isn't enough usage of citec/harvc to have a consensus of where people want their book chapters to appear, but I like keeping book chapters of the same book together, not in separate sections of the article, just because some of the chapters are not (yet) cited. Mathglot ( talk) 19:19, 23 October 2023 (UTC) reply
{{ sfn whitelist}} is for Module:Footnotes-generated errors; it has no meaning to HarvErrors.js. HarvErrors.js will never recognize {{sfn whitelist}} because that template does not create output that is visible in the article's html (where HarvErrors.js operates).
If Delgado and the others are not cited in the body of the article, they are cruft that should be removed. I agree that (when used) {{ harvc}} templates should be near the cs1|2 template ( Template:Harvc § Basic example illustrates my preferred style). Not used, hide or remove.
Trappist the monk ( talk) 19:41, 23 October 2023 (UTC) reply
 Resolved. Thanks, resolved using {{ cite whitelink}}, which I created a few months ago for this type of situation, and then promptly forgot about. Mathglot ( talk) 03:37, 24 October 2023 (UTC) reply

Unexpected "no-links" warnings

I'm seeing unexpected "no-links" warnings at Collaborationism in France during the Second World War in section "#Reviews", which isn't one of the sections I thought it emitted warnings for. Mathglot ( talk) 11:39, 22 November 2023 (UTC) reply

Are you sure? The script suppresses some messaging for citations found in §Further reading, §External links, and §Publications; all other sections will show messaging.
Rename Collaborationism in France during the Second World War § Reviews to Collaborationism in France during the Second World War § Publications and preview – it will show that the Peyre and Watson citations are probably in the wrong place and the warning messages will be suppressed.
Trappist the monk ( talk) 00:07, 23 November 2023 (UTC) reply

Warnings incorrectly show in multiref(2) if author mentioned and Sfn used on page

I often use Template:Multiref2 to bundle sources. I have noticed that some of the bundled citations incorrectly display Harv warnings. I was able to narrow it down.

If the page uses Sfn (or harv) citations anywhere on the page, then a multiref-bundled cite-web citation with a name parameter (|author= or |last=) will incorrectly display the error. The harv warning is NOT displayed for bundled citations that do NOT use names. The warning doesn't display if I unbundle the citations (ref them separately instead of putting them in a multiref container). And the harv warning is NOT displayed if Sfn or Harv are never once used on the page.

I made a sample page to show the behavior: User:Grorp/sandbox4

It is written like a bug report, with instructions for an interaction. You can edit the page and remove the one instance using Sfn and you'll see the anomaly disappear.

It doesn't make sense that the same citation which doesn't generate a warning, does show a warning if bundled into multiref or multiref2.   ▶ I am Grorp ◀ 01:04, 23 January 2024 (UTC) reply

Working as it is intended to work.
cs1|2 templates create CITEREF id attributes for each citation's enclosing <cite>...</cite> tag only when there is an author, contributor, or editor name.
When there are no {{ sfn}} or {{harv}}-family templates in a page, HarvErrors does not check for errors and so does not emit error and warning messages.
When the page has {{sfn}} or {{harv}}-family templates, HarvErrors emits the no-link-pointing-to-this-citation warning message when a cs1|2 citation has a CITEREF id and when the citation is not inside its own <ref>...</ref> tags or is not in §Further reading, §External links, or §Publications sections.
You are seeing the warnings because the two citations inside {{ multiref2}} have author names (CITEREF ids) but are not wrapped inside their own <ref>...</ref> tags (and are outside of any §Further reading, §External links, and §Publications sections).
You can suppress the warning message by adding |ref=none to the two cs1|2 templates with author names.
Trappist the monk ( talk) 14:50, 23 January 2024 (UTC) reply

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook