Open main menu

Wikipedia β

User:Ucucha/HarvErrors

< User:Ucucha

Harvard citation templates like {{Sfn}} are prone to problems with their automatically generated links (see [1] for an extreme example). User:Ucucha/HarvErrors.js (based on User:Svick/HarvErrors.js) checks these links for validity and displays an error message for incorrect links. In addition, it checks for citations that are set up to receive links, but do not have any pointing to them.

For example, the following code produces an incorrect link and a citation without anything pointing to it:

Text{{Sfn|Smith|2011|p=9}}

{{reflist}}
==References==
*{{cite book|last=Smith|first=John|year=2010|title=A Book|publisher=A Publisher|ref=harv}}

Text[1]

  1. ^ Smith 2011, p. 9.

ReferencesEdit

  • Smith, John (2010). A Book. A Publisher. 

With the script installed, this looks as follows:

Text[1]

  1. ^ Smith 2011, p. 9. Harv error: link to #CITEREFSmith2011 doesn't point to any citation.

ReferencesEdit

  • Smith, John (2010). A Book. A Publisher.  Harv error: There is no link pointing to this citation.

Installation and customizationEdit

To install the script, add:

importScript('User:Ucucha/HarvErrors.js');

to Special:MyPage/common.js.

If installed correctly, you will see a red error message at the end of this sentence: (NoAuthor 2011). If you don't see an error message, you may still need to bypass your cache.

The check for citations that have no links pointing to them is prone to false positives, because citations do not always need to have such links. For example, the citation may be in a "Further reading" section or Harvard citations are not used in an article. Therefore, it is possible to disable this part of the script. Simply add:

window.checkLinksToCitations = false;

to your common.js page.

Fixing problemsEdit

The problems caught by this script often have one of the following causes:

  • The work cited in the Harvard citation is not in the list of references. In this case, add *{{cite journal|last=Smith|year=2011 ... to the list.
  • The work cited is in the reference list, but does not have |ref=harv set. This is necessary for a Harvard citation to work.
  • The authors or date in the Harvard citation and the citation in the reference list do not match exactly. For example, the spelling of one of the names may be incorrect, or the year may be in a parameter called |date= instead of |year=.
  • A work listed in the reference list was previously cited in an article, but all Harvard citations pointing to it have been removed.