User:Mathglot/HarvErrors
Description | Finds problems with {{ harv}}-style footnotes |
---|---|
Author(s) | User:Trappist the monk, User:Mathglot |
Maintainer(s) | User:Mathglot |
Updated | August 21, 2023 (8 months ago) |
Source | User:Mathglot/HarvErrors.js |
What it does
This script may produce any of three types of error messages, and one type of warning message. Here are some sample messages, explained:
- Error messages
- Harv error: link from "CITEREFSmith1981" doesn't point to any citation. – You included short footnote
{{sfn|Smith|1981}}
inline, but there is no matchingBibliography or Works citedsection in the Appendix. This message is dark orange by default. - Harv error: "CITEREFJones2004" has multiple targets (2x). – You included short footnote
{{sfn|Jones|2004}}
inline, but there are twoBibliography or Works cited sectionin the Appendix that are both targeted by this short footnote. This may occur, for example, when Jones has two publications in 2004. Violet by default. - Harv error: linked from "CITEREFAnderson2021". – This is a "wrong section" error; You included short footnote
{{sfn|Anderson|2021}}
inline, and there is a valid full citation for it in the bottom matter, but it's in the wrong section, such as "Further reading". It should be in either "Bibliography", or "Works cited" (which must be a level two section heading). Dark orange by default.
- Warning message
-
Harv warning: There is no link pointing to this citation. The anchor is named "CITEREFMqrtindale1997". – You included an item in the Bibliography or Works cited section, but there isn't a matching short footnote 'inline, or maybe you included it, but the year or last names don't match—as in this example, where a typo in the full citation causes a match failure, resulting in the warning. Brownish by default.
{{sfn|Mqrtindale|1997}}
' anywhere in the body with the same last-name and year. Maybe you forgot to include a short footnote
Resolving errors
Error messages #1 and 2
Installation
To install this script, add:
mw.loader.load( '/w/index.php?title=User:Trappist_the_monk/HarvErrors.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Trappist the monk/HarvErrors.js]]
Simple testcases page at User:Mathglot/HarvErrors/testcases.
Style customization
There are three undefined css classes that can be used in your common
ttm_harv_err
– default color is DarkOrange#FF8C00
ttm_harv_warn
– default color is some-sort-of brown#AC6600
ttm_harv_err_dup
– default color is some-sort-of purple#C3F
You can customize the font color or other
- ➢
body .ttm_harv_err {color:green}
– displays the message in green, instead of the dark orange default: ⟶- Harv error: link from "CITEREFSmith1981" doesn't point to any citation.
- ➢
body .ttm_harv_err_dup {color:#AA00AA; border:thin solid gray; background-color:cornsilk}
adds color, a gray border, and light shading, like this ⟶- Harv error: "CITEREFJones2004" has multiple targets (2x)
- ➢
body .ttm_harv_warn {color:#793300; text-decoration:wavy wheat underline}
– darker brown, and underlined ⟶- Harv warning: There is no link pointing to this citation. The anchor is named "CITEREFMoiré2004".
For more color choices, see
Similar errors and warnings
Error or warning messages from other sources may appear similar to the ones generated by this script. You may notice the following error messages generated by Module:Footnotes:
- sfn error: no target: CITEREFNowhereman2024 (help) – this is similar to error message #1 above. You may see just one, or both right next to each other, depending on your preferences, and script or css settings.
- sfn error: multiple targets (2×): CITEREFDoubleton2005 (help) – this is similar to error message #2 above; and you might see either, or both of them.
If you wish to distinguish errors generated by the module from those generated by this script, you can apply css style to them using class harv-error in your common.css, similar to style customization above. This will tag errors from the module with a prefix:
- ➢
.harv-error::before{content: "Mod:FN: "}
⟶ Mod:FN: sfn error: no target: CITEREFNowhereman2024 ...
Known issues
- (none at present)