Jump to content

User:Chocolateboy/smart quotes.user.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
==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>&nbsp;should appear as smart quotes: “double quotes”
* <code>singlehyphen</code>&nbsp;should appear as an en dash: single–hyphen
* <code>double  hyphen</code>&nbsp;should appear as an em dash: double — hyphen
* <code>ellipsis</code>&nbsp;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]