User talk:Gimmetrow/replace.js
From Wikipedia, the free encyclopedia
This javascript can be added to monobook.js with {{subst:js|User:Gimmetrow/replace.js}}. It assumes the addLink function exists; if this is not included by a prior script, then add {{subst:js|User:Omegatron/monobook.js/addlink.js}} before this script. This javascript creates two tabs visible when a page is being edited:
- regexp: a general search/replace tab handled with popup prompts
- fix refs: a tab to format ref marks in accord with WP:FN.
The WP:FN guideline says that refs should follow punctuation with no space, and no space between successive refs. This tab applies that style, and is intended to clear up the inconsistent location of punctuation and ref marks that sometimes occurs in heavily-edited articles. (Some editors prefer spaces between successive refs, but if that style is used consistently it shouldn't be changed in articles.)
Also adjusts {{fact}}, {{citation needed}}, {{cn}}, {{citequote}}, {{verification needed}}, and {{verify source}}, as well as {{ref}}, {{ref_label}}, {{cref}} and {{GR}} to some extent.
The tab handles the following:
- This [1] , this [2] ; and this. [3] . [4] .
- This [5] , this [6] ; and this. [7] , [8] ?
- This [5] , this [6] : and this. [7] ? [8] !
- Fact tags [citation needed] [citation needed] ; [citation needed] .
- Other tags verification needed] : [verification needed] . , [
- {{ref}} and {{GR}} GR2 : and colons.
- Works with tags inside refs [9] , named or not [10].
- A ref text containing the text "</refzzzzz>" [11]!
- Compresses multiple refs up to 10 in a row [5] [6] [7] [8] [12] .
- Also removes linebreaks.[5] [6][6]
- Also "quotes," [19] , and "quotes;" [5] .
- Single 'quotes,' [6] ; and 'closing smart-quotes,’ [7] !
- "Quotes"[6], "quotes"[6]; "quotes"[6].
- "Quotes."[6], "quotes."[6]; "quotes."[6].
- "Quotes?"[6], "quotes?"[6]; "quotes?"[6].
- "Quotes:"[6], "quotes;"[6]: "quotes:"[6]!
- "Quotes,"[6]! "quotes;"[6]! "quotes."[6]!
- "Quotes?"[6]! "quotes!?!"[6]? "quotes?"[6]!?!
- Does "some 'quotes within quotes,'" [5] ; .
- Multiple punctuation is fixed after a ref [5] .;.,.
- Allows spaces in some templates, like {{ fact }} [citation needed] .
- Allows capitalization, like {{ Fact }} and <REF> [citation needed] [5].
- <references/> tag remains untouched.
- Known issues to look out for
- Messes up abbreviations in "quotes, eg."[5], and not eg. [6];
- Messes up ellipsis in "quotes..."[5], and without quotes [6] ...
- If there is no following punctuation, the ref/abbreviation/ellipsis is unchanged
- Refs with dashes and parenthesis not addressed
- Comments can abscure matches <ref>like so</ref><!-- comment -->.
- Refs within comments are adjusted too <!-- <ref>like so</ref> -->
- Removes spaces before trailing > in named refs, as in <ref name="a b c"/ >.
- This forces <ref name="abc"/ > to be the same as <ref name="abc"/>.
- This is only an issue for ref names ending in / outside quotes
- Ref may parse the above differently after spaces are removed - ideally avoid this
- Compare <ref name="abc"/ > Stuff.<ref name="cde/" >text</ref>
- Obscure or unlikely to occur in real articles
- Repeated ? or ! both kept outside a quote? [5]!
- Ref parses a nowiki'ed /ref tag as end of text: [20]</nowiki>.</ref>!