User:Chocolateboy/smart quotes.user.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Chocolateboy/smart quotes.user. |
==Description==
This [[Greasemonkey]] user script converts typewriter quotation marks to “smart” quotes and triple periods to [[ellipsis|ellipses]]. Text inside <nowiki><pre>…</pre></nowiki> and <nowiki><code>…</code></nowiki> is not affected.
==Usage==
# Install [http://greasemonkey.mozdev.org/ Greasemonkey] >= 0.3
# Open the URL in the Script section below
==Test==
* <code>“double quotes”</code> should appear as smart quotes: “double quotes”
* <code>single–hyphen</code> should appear as an en dash: single–hyphen
* <code>double — hyphen</code> should appear as an em dash: double — hyphen
* <code>ellipsis…</code> should appear as a single character: ellipsis…
==Script==
* https://raw.github.com/chocolateboy/userscripts/master/wikipedia_smart_quotes.user.js
==Changelog==
* 1.0.1 don't change hyphens to dashes
* 1.0.0 add support for HTTPS; support other languages; add grant
* 0.14 refine exclusions
* 0.13 exclude diffs
* 0.12 exclude articles with unbalanced quotation marks
* 0.11 var cleanup
* 0.10 remove redundant loop
* 0.09 order the replacements so that double hyphens are processed before single hyphens
* 0.08 properly fix ellipsis regex
* 0.07 exclude preformatted text
* 0.06 access text node children of <nowiki><body></nowiki> rather than <nowiki><p></nowiki> so that <nowiki><li></nowiki> nodes are included
* 0.05 better handling of double quotes
* 0.04 further constrain ellipsis regex + correct JavaScript replacement pattern syntax
* 0.03 fix ellipsis regex
* 0.02 only modify text nodes that are descendants of <nowiki><p></nowiki> nodes
* 0.01 original version
==See also==
* [[Wikipedia talk:Manual of Style (dashes)]]
* [[Wikipedia talk:Manual of Style (dates and numbers)]]
* [[Wikipedia talk:Manual of Style (Quotation marks and apostrophes)]]
==External links==
* [http://diveintogreasemonkey.org/videos/install–user–script.html How to install a Greasemonkey user script] ([[Macromedia Flash|Flash]] video)
* [http://diveintogreasemonkey.org/casestudy/dumbquotes.html DumbQuotes]