Document and update smartquotes.
[docutils.git] / docutils / docs / user / smartquotes.txt
blob8bc045afee046d61afa6bcd156b8ec82473ae5bf
1 =========================
2 Smart Quotes for Docutils
3 =========================
5 :Author: Günter Milde,
6          based on SmartyPants by John Gruber, Brad Choate, and Chad Miller
7 :Contact: docutils-develop@lists.sourceforge.net
8 :Revision: $Revision$
9 :Date: $Date$
10 :License: Released under the terms of the `2-Clause BSD license`_
11 :Abstract: This document describes the Docutils `smartquotes` module.
13 .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
15 .. contents::
17 Description
18 ===========
20 The `smart_quotes configuration setting`_ triggers the SmartQuotes
21 transformation on Text nodes that includes the following steps:
23 - Straight quotes (``"`` and ``'``) into "curly" quote characters
24 - dashes (``--`` and ``---``) into en- and em-dash entities
25 - three consecutive dots (``...`` or ``. . .``) into an ellipsis entity.
27 This means you can write, edit, and save your documents using plain old
28 ASCII---straight quotes, plain dashes, and plain dots---while Docutils
29 generates documents with typographical quotes, dashes, and ellipses.
31 Advantages:
33 * typing speed (especiall when blind-typing),
34 * the possibility to change the quoting style of the
35   complete document with just one configuration option, and
36 * restriction to 7-bit characters in the source.
38 However, there are `algorithmic shortcomings`_ for 2 reasons:
40 * Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe,
41 * languages that do not use whitespace around words.
43 So, please consider also
44 `Why You Might Not Want to Use "Smart" Quotes in Your Documents`_.
46 .. _smart_quotes configuration setting: config.html#smart-quotes
49 Escaping
50 ========
52 The `SmartQuotes` transform does not modify characters in literal text
53 such as source code, maths, or literal blocks.
55 If you need literal straight quotes (or plain hyphens and periods) in normal
56 text, you can backslash escape the characters to preserve
57 ASCII-punctuation. You need two backslashes as one backslash is removed by
58 the reStructuredText `escaping mechanism`_.
60 ========  =========  ========  =========
61 Escape    Character  Escape    Character
62 ========  =========  ========  =========
63 ``\\``    \\         ``\\.``   \\.
64 ``\\"``   \\"        ``\\-``   \\-
65 ``\\'``   \\'        ``\\```   \\`
66 ========  =========  ========  =========
68 This is useful, for example, when you want to use straight quotes as
69 foot and inch marks: 6\\'2\\" tall; a 17\\" iMac.
71 .. _escaping mechanism: ../ref/rst/restructuredtext.html#escaping-mechanism
74 Localisation
75 ============
77 Quotation marks have a `variety of forms`__ in different languages and
78 media.
80 `Smartquotes` selects quotation marks depending on the language of the current
81 block element and the value of the `smart_quotes configuration setting`_.
83 __ https://en.wikipedia.org/wiki/Quotation_mark#Summary_table
85 Docutils' `smartquotes` support the following languages:
88 .. class:: language-af
90 "'Afrikaans' quotes"
92 .. class:: language-af-x-altquot
94 "'Afrikaans' alternative quotes"
96 .. class:: language-ca
98 "'Catalan' quotes"
100 .. class:: language-ca-x-altquot
102 "'Catalan' alternative quotes"
104 .. class:: language-cs
106 "'Czech' quotes"
108 .. class:: language-cs-x-altquot
110 "'Czech' alternative quotes"
112 .. class:: language-da
114 "'Danish' quotes"
116 .. class:: language-da-x-altquot
118 "'Danish' alternative quotes"
120 .. class:: language-de
122 "'German' quotes"
124 .. class:: language-de-x-altquot
126 "'German' alternative quotes"
128 .. class:: language-de-ch
130 "'Swiss-German' quotes"
132 .. class:: language-el
134 "'Greek' quotes"
136 .. class:: language-en
138 "'English' quotes"
140 .. class:: language-en-uk-x-altquot
142 "'British' alternative quotes"
143 (swaps single and double quotes: ``"`` → ‘ and ``'`` → “)
145 .. class:: language-eo
147 "'Esperanto' quotes"
149 .. class:: language-es
151 "'Spanish' quotes"
153 .. class:: language-es-x-altquot
155 "'Spanish' alternative quotes"
157 .. class:: language-et
159 "'Estonian' quotes" (no secondary quote listed in Wikipedia)
161 .. class:: language-et-x-altquot
163 "'Estonian' alternative quotes"
165 .. class:: language-eu
167 "'Basque' quotes"
169 .. class:: language-fi
171 "'Finnish' quotes"
173 .. class:: language-fi-x-altquot
175 "'Finnish' alternative quotes"
177 .. class:: language-fr
179 "'French' quotes"
181 .. class:: language-fr-x-altquot
183 "'French' alternative quotes"
185 .. class:: language-fr-ch
187 "'Swiss-French' quotes"
189 .. class:: language-fr-ch-x-altquot
191 "'Swiss-French' alternative quotes" (narrow no-break space, see
192 http://typoguide.ch/)
194 .. class:: language-gl
196 "'Galician' quotes"
198 .. class:: language-he
200 "'Hebrew' quotes"
202 .. class:: language-he-x-altquot
204 "'Hebrew' alternative quotes"
206 .. class:: language-hr
208 "'Croatian' quotes"
210 .. class:: language-hr-x-altquot
212 "'Croatian' alternative quotes"
214 .. class:: language-hsb
216 "'Upper Sorbian' quotes"
218 .. class:: language-hsb-x-altquot
220 "'Upper Sorbian' alternative quotes"
222 .. class:: language-hu
224 "'Hungarian' quotes"
226 .. class:: language-is
228 "'Icelandic' quotes"
230 .. class:: language-it
232 "'Italian' quotes"
234 .. class:: language-it-ch
236 "'Swiss-Italian' quotes"
238 .. class:: language-it-x-altquot
240 "'Italian' alternative quotes"
242 .. class:: language-ja
244 "'Japanese' quotes"
246 .. class:: language-lt
248 "'Lithuanian' quotes"
250 .. class:: language-lv
252 "'Latvian' quotes"
254 .. class:: language-nl
256 "'Dutch' quotes"
258 .. class:: language-nl-x-altquot
260 "'Dutch' alternative quotes"
262 .. # 'nl-x-altquot2': u'””’’',
264 .. class:: language-pl
266 "'Polish' quotes"
268 .. class:: language-pl-x-altquot
270 "'Polish' alternative quotes"
272 .. class:: language-pt
274 "'Portuguese' quotes"
276 .. class:: language-pt-br
278 "'Portuguese (Brazil)' quotes"
280 .. class:: language-ro
282 "'Romanian' quotes"
284 .. class:: language-ru
286 "'Russian' quotes"
288 .. class:: language-sh
290 "'Serbo-Croatian' quotes"
292 .. class:: language-sh-x-altquot
294 "'Serbo-Croatian' alternative quotes"
296 .. class:: language-sk
298 "'Slovak' quotes"
300 .. class:: language-sk-x-altquot
302 "'Slovak' alternative quotes"
304 .. class:: language-sl
306 "'Slovenian' quotes"
308 .. class:: language-sl-x-altquot
310 "'Slovenian' alternative quotes"
312 .. class:: language-sr
314 "'Serbian' quotes"
316 .. class:: language-sr-x-altquot
318 "'Serbian' alternative quotes"
320 .. class:: language-sv
322 "'Swedish' quotes"
324 .. class:: language-sv-x-altquot
326 "'Swedish' alternative quotes"
328 .. class:: language-tr
330 "'Turkish' quotes"
332 .. class:: language-tr-x-altquot
334 "'Turkish' alternative quotes"
336 .. 'tr-x-altquot2': u'“„‘‚', # antiquated?
338 .. class:: language-uk
340 "'Ukrainian' quotes"
342 .. class:: language-uk-x-altquot
344 "'Ukrainian' alternative quotes"
346 .. class:: language-zh-cn
348 "'Chinese (China)' quotes"
350 .. class:: language-zh-tw
352 "'Chinese (Taiwan)' quotes"
354 Quotes in text blocks in a non-supported language use the document
355 language:
357 .. class:: langugage-undefined-example
359 "'Undefined' quotes"
362 Caveats
363 =======
365 Why You Might Not Want to Use "Smart" Quotes in Your Documents
366 --------------------------------------------------------------
368 For one thing, you might not care.
370 Most normal, mentally stable individuals do not take notice of proper
371 typographic punctuation. Many design and typography nerds, however, break
372 out in a nasty rash when they encounter, say, a restaurant sign that uses
373 a straight apostrophe to spell "Joe's".
375 If you're the sort of person who just doesn't care, you might well want to
376 continue not caring. Using straight quotes -- and sticking to the 7-bit
377 ASCII character set in general -- is certainly a simpler way to live.
379 Even if you *do* care about accurate typography, you still might want to
380 think twice before "auto-educating" the quote characters in your documents.
381 As there is always a chance that the algorithm gets it wrong, you may
382 instead prefer to use the compose key or some other means to insert the
383 correct Unicode characters into the source.
386 Algorithmic Shortcomings
387 ------------------------
389 The ASCII character (u0027 APOSTROPHE) is used for apostrophe and single
390 quotes. If use inside a word, it is converted into an apostrophe:
392    .. class:: language-fr
394    Il dit : "C'est 'super' !"
396 At the beginning or end of a word, it cannot be distinguished from a single
397 quote by the algorithm.
399 The `right single quotation mark`_ character -- used to close a secondary
400 (inner) quote in English -- is also "the preferred character to use for
401 apostrophe" (Unicode_). Therefore, "educating" works as expected for
402 apostrophes at the end of a word, e.g.,
404   Mr. Hastings' pen; three days' leave; my two cents' worth.
406 However, when apostrophes are used at the start of leading contractions,
407 "educating" will turn the apostrophe into an *opening* secondary quote. In
408 English, this is *not* the apostrophe character, e.g., ``'Twas brillig``
409 is "miseducated" to
411   'Twas brillig.
413 In other locales (French, Italian, German, ...), secondary closing quotes
414 differ from the apostrophe. A text like::
416    .. class:: language-de-CH
418    "Er sagt: 'Ich fass' es nicht.'"
420 becomes
422    .. class:: language-de-CH
424    "Er sagt: 'Ich fass' es nicht.'"
426 with a single closing guillemet in place of the apostrophe.
428 In such cases, it's best to use the recommended apostrophe character (’) in
429 the source:
431    | ’Twas brillig, and the slithy toves
432    | Did gyre and gimble in the wabe;
433    | All mimsy were the borogoves,
434    | And the mome raths outgrabe.
436 .. _right single quotation mark:
437     http://www.fileformat.info/info/unicode/char/2019/index.htm
438 .. _Unicode: http://www.unicode.org/charts/PDF/U2000.pdf
440 History
441 =======
443 The smartquotes module is an adaption of "SmartyPants_" to Docutils.
445 `John Gruber`_ did all of the hard work of writing this software in Perl for
446 `Movable Type`_ and almost all of this useful documentation.  `Chad Miller`_
447 ported it to Python to use with Pyblosxom_.
449 Portions of the SmartyPants original work are based on Brad Choate's nifty
450 MTRegex plug-in.  `Brad Choate`_ also contributed a few bits of source code to
451 this plug-in.  Brad Choate is a fine hacker indeed.
452 `Jeremy Hedley`_ and `Charles Wiltgen`_ deserve mention for exemplary beta
453 testing of the original SmartyPants.
455 Internationalization and adaption to Docutils by Günter Milde.
457 .. _SmartyPants: http://daringfireball.net/projects/smartypants/
458 .. _Pyblosxom: http://pyblosxom.bluesock.org/
459 .. _Movable Type: http://www.movabletype.org/
460 .. _John Gruber: http://daringfireball.net/
461 .. _Chad Miller: http://web.chad.org/
462 .. _Brad Choate: http://bradchoate.com/
463 .. _Jeremy Hedley: http://antipixel.com/
464 .. _Charles Wiltgen: http://playbacktime.com/
465 .. _Rael Dornfest: http://raelity.org/