User:SMcCandlish/TidyRefs
From Wikipedia, the free encyclopedia
User:SMcCandlish/TidyRefs.js is a user JavaScript for your common.js page. It adds two options to the "Tools" menu (on the left in most skins), "<Tidy>" and "<Tidy> (vertically)" [the latter still in development]. These only appear in the menu when in editing mode.
- "<Tidy>" normalizes all horizontal
<ref>
citation code throughout the article to have consistent spacing within, quoted attribute values, and lowercased tag and attribute names. This includes<ref>...</ref>
and<ref />
instances, and also includes fixing visually disruptive vertical ones to be horizontal. - "<Tidy> (vertically)" - [Forthcoming.] When developed, this will format
<ref>...</ref>
tags vertically in some sane manner, with consistent spacing plus the quote-marks fixes, and should only be used in a page-bottom citations section that is using vertical citations in list-defined references (LDR) style.- In an article using LDR, the article body will contain horizontal citations, and the LDR references at the bottom may be vertical (though this is not required). In such a case of mixed citation formatting, the way to use these scripts is to copy–paste the vertical LDR references into a user sandbox, run "<Tidy>" on the entire article (don't save it yet), run "<Tidy> (vertically)", when available, on the vertical references in the sandbox, and copy the vertical references back out from the sandbox and paste them over the undesirably horizontalized ones at the bottom of the article.
TidyRefs | |
---|---|
Description | Harmonize spacing and attribute value quoting in <ref> tags |
Author(s) | SMcCandlish |
Status | Working for core functionality (more features in development) |
Updated | 24 January 2024; 4 months ago (2024-01-24) |
Browser support | Likely all |
Skin support | Likely all |
Source | User:SMcCandlish/TidyRefs.js |
Various features of this script are still under development. Use with caution, and be sure to examine the output carefully, and use Preview before saving to make sure citations are all working properly. It is highly advisable to follow the instructions at User:Ucucha/HarvErrors to install his script for detecting broken citations, and Help:CS1 errors § Error and maintenance messages to install the CSS to display both sorts of citation warning messages. Fix any flagged errors (you will need to edit the page and do Preview to make all the error/warning messages available) before trying to run TidyRefs or any other citation cleanup script. Garbage in, garbage out! Take out the garbage first. |
Usually, neither function should be used without also making a more substantive change (at least fix a typo or something) in the same edit, per the human-editor rules at WP:COSMETICBOT.
This script does not do anything with CS1/CS2 citation templates ({{cite web}}
, {{cite journal}}
, {{citation}}
, etc.), that are the content between the <ref>...</ref>
tags (i.e., it does not clean up {{cite journal | last = Ceedie | first = A. B. | title = My Book | ... }}
to {{cite book |last=Ceedie |first=A. B. |title=My Book |...}}
). The script for doing that, to run along with TidyRefs, is User:SMcCandlish/TidyCitations.