File: smartquotes.txt

package info (click to toggle)
python-docutils 0.21.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,900 kB
  • sloc: python: 50,310; lisp: 14,475; xml: 1,810; javascript: 1,032; makefile: 107; sh: 78
file content (485 lines) | stat: -rw-r--r-- 12,124 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
.. include:: ../header.txt

=========================
Smart Quotes for Docutils
=========================

:Author: Günter Milde,
         based on SmartyPants by John Gruber, Brad Choate, and Chad Miller
:Contact: docutils-develop@lists.sourceforge.net
:Revision: $Revision: 9051 $
:Date: $Date: 2022-04-02 23:59:06 +0200 (Sa, 02. Apr 2022) $
:License: Released under the terms of the `2-Clause BSD license`_
:Abstract: This document describes the Docutils `smartquotes` module.

.. _2-Clause BSD license: http://opensource.org/licenses/BSD-2-Clause

.. contents::

Description
===========

The `"smart_quotes" configuration setting`_ triggers the SmartQuotes
transformation on Text nodes that includes the following steps:

- Straight quotes (``"`` and ``'``) into "curly" quote characters
- dashes (``--`` and ``---``) into en- and em-dash entities
- three consecutive dots (``...`` or ``. . .``) into an ellipsis entity.

This means you can write, edit, and save your documents using plain old
ASCII -- straight quotes, plain dashes, and plain dots -- while Docutils
generates documents with typographical quotes, dashes, and ellipses.

Advantages:

* Typing speed (especially when blind-typing).
* The possibility to change the quoting style of the
  complete document with just one configuration option.
* Typographical quotes with just 7-bit ASCII characters in the source.

However, there are `algorithmic shortcomings`_ for 2 reasons:

* Dual use of the "ASCII-apostrophe" (') as single quote and apostrophe.
* Languages that do not use whitespace around words.

So, please consider also
`Why You Might Not Want to Use "Smart" Quotes in Your Documents`_.

.. _"smart_quotes" configuration setting:
.. _"smart_quotes" setting: config.html#smart-quotes


Escaping
========

The `SmartQuotes` transform does not modify characters in literal text
such as source code, maths, or literal blocks.

If you need literal straight quotes (or plain hyphens and periods) in normal
text, you can `backslash escape`_ the characters to preserve
ASCII-punctuation.

.. class:: booktabs

=========  ========= == ========  ==========
Input      Output       Input     Output
=========  ========= == ========  ==========
``\\``     \\           ``\...``  \...
``\"``     \"           ``\--``   \--
``\'``     \'           ``\```    \`
=========  ========= == ========  ==========

This is useful, for example, when you want to use straight quotes as
foot and inch marks:

  6\'2\" tall; a 17\" monitor.

.. _backslash escape: ../ref/rst/restructuredtext.html#escaping-mechanism


Localization
============

Quotation marks have a `variety of forms`__ in different languages and
media.

__ https://en.wikipedia.org/wiki/Quotation_mark#Summary_table

`SmartQuotes` inserts quotation marks depending on the language of the
current block element and the value of the `"smart_quotes" setting`_.\
[#x-altquot]_
There is built-in support for the following languages:\ [#smartquotes-locales]_

.. class:: run-in

:af: .. class:: language-af

    "'Afrikaans' quotes"

:af-x-altquot: .. class:: language-af-x-altquot

    "'Afrikaans' alternative quotes"

:ca: .. class:: language-ca

    "'Catalan' quotes"

:ca-x-altquot: .. class:: language-ca-x-altquot

    "'Catalan' alternative quotes"

:cs: .. class:: language-cs

    "'Czech' quotes"

:cs-x-altquot: .. class:: language-cs-x-altquot

    "'Czech' alternative quotes"

:da: .. class:: language-da

    "'Danish' quotes"

:da-x-altquot: .. class:: language-da-x-altquot

    "'Danish' alternative quotes"

:de: .. class:: language-de

    "'German' quotes"

:de-x-altquot: .. class:: language-de-x-altquot

    "'German' alternative quotes"

:de-ch: .. class:: language-de-ch

    "'Swiss-German' quotes"

:el: .. class:: language-el

    "'Greek' quotes"

:en: .. class:: language-en

    "'English' quotes"

:en-uk-x-altquot: .. class:: language-en-uk-x-altquot

    "'British' alternative quotes" (swaps single and double quotes)

:eo: .. class:: language-eo

    "'Esperanto' quotes"

:es: .. class:: language-es

    "'Spanish' quotes"

:es-x-altquot: .. class:: language-es-x-altquot

    "'Spanish' alternative quotes"

:et: .. class:: language-et

    "'Estonian' quotes" (no secondary quote listed in Wikipedia)

:et-x-altquot: .. class:: language-et-x-altquot

    "'Estonian' alternative quotes"

:eu: .. class:: language-eu

    "'Basque' quotes"

:fi: .. class:: language-fi

    "'Finnish' quotes"

:fi-x-altquot: .. class:: language-fi-x-altquot

    "'Finnish' alternative quotes"

:fr: .. class:: language-fr

    "'French' quotes"

:fr-x-altquot: .. class:: language-fr-x-altquot

    "'French' alternative quotes"

:fr-ch: .. class:: language-fr-ch

    "'Swiss-French' quotes"

:fr-ch-x-altquot: .. class:: language-fr-ch-x-altquot

    "'Swiss-French' alternative quotes" (narrow no-break space, see
    http://typoguide.ch/)

:gl: .. class:: language-gl

    "'Galician' quotes"

:he: .. class:: language-he

    "'Hebrew' quotes"

:he-x-altquot: .. class:: language-he-x-altquot

    "'Hebrew' alternative quotes"

:hr: .. class:: language-hr

    "'Croatian' quotes"

:hr-x-altquot: .. class:: language-hr-x-altquot

    "'Croatian' alternative quotes"

:hsb: .. class:: language-hsb

    "'Upper Sorbian' quotes"

:hsb-x-altquot: .. class:: language-hsb-x-altquot

    "'Upper Sorbian' alternative quotes"

:hu: .. class:: language-hu

    "'Hungarian' quotes"

:is: .. class:: language-is

    "'Icelandic' quotes"

:it: .. class:: language-it

    "'Italian' quotes"

:it-ch: .. class:: language-it-ch

    "'Swiss-Italian' quotes"

:it-x-altquot: .. class:: language-it-x-altquot

    "'Italian' alternative quotes"

:ja: .. class:: language-ja

    "'Japanese' quotes"

:lt: .. class:: language-lt

    "'Lithuanian' quotes"

:lv: .. class:: language-lv

    "'Latvian' quotes"

:nl: .. class:: language-nl

    "'Dutch' quotes"

:nl-x-altquot: .. class:: language-nl-x-altquot

    "'Dutch' alternative quotes"

    .. # 'nl-x-altquot2': '””’’',

:pl: .. class:: language-pl

    "'Polish' quotes"

:pl-x-altquot: .. class:: language-pl-x-altquot

    "'Polish' alternative quotes"

:pt: .. class:: language-pt

    "'Portuguese' quotes"

:pt-br: .. class:: language-pt-br

    "'Portuguese (Brazil)' quotes"

:ro: .. class:: language-ro

    "'Romanian' quotes"

:ru: .. class:: language-ru

    "'Russian' quotes"

:sh: .. class:: language-sh

    "'Serbo-Croatian' quotes"

:sh-x-altquot: .. class:: language-sh-x-altquot

    "'Serbo-Croatian' alternative quotes"

:sk: .. class:: language-sk

    "'Slovak' quotes"

:sk-x-altquot: .. class:: language-sk-x-altquot

    "'Slovak' alternative quotes"

:sl: .. class:: language-sl

    "'Slovenian' quotes"

:sl-x-altquot: .. class:: language-sl-x-altquot

    "'Slovenian' alternative quotes"

:sr: .. class:: language-sr

    "'Serbian' quotes"

:sr-x-altquot: .. class:: language-sr-x-altquot

    "'Serbian' alternative quotes"

:sv: .. class:: language-sv

    "'Swedish' quotes"

:sv-x-altquot: .. class:: language-sv-x-altquot

    "'Swedish' alternative quotes"

:tr: .. class:: language-tr

    "'Turkish' quotes"

:tr-x-altquot: .. class:: language-tr-x-altquot

    "'Turkish' alternative quotes"

.. 'tr-x-altquot2': '“„‘‚', # antiquated?

:uk: .. class:: language-uk

    "'Ukrainian' quotes"

:uk-x-altquot: .. class:: language-uk-x-altquot

    "'Ukrainian' alternative quotes"

:zh-cn: .. class:: language-zh-cn

    "'Chinese (China)' quotes"

:zh-tw: .. class:: language-zh-tw

    "'Chinese (Taiwan)' quotes"

Quotes in text blocks in a non-configured language are kept as plain quotes:

:undefined: .. class:: language-undefined-example

    "'Undefined' quotes"

.. [#x-altquot] Tags with the non-standard extension ``-x-altquot`` define
   the quote set used with the `"smart_quotes" setting`_ value ``"alt"``.

.. [#smartquotes-locales] The definitions for language-dependend
   typographical quotes can be extended or overwritten using the
   `"smartquotes_locales" setting`_.

   The following example ensures a correct leading apostrophe in ``'s
   Gravenhage`` (at the cost of incorrect leading single quotes) in Dutch
   and sets French quotes to double and single guillemets with inner
   spacing::

     smartquote-locales: nl: „”’’
                         fr: « : »:‹ : ›

.. _"smartquotes_locales" setting: config.html#smartquotes-locales


Caveats
=======

Why You Might Not Want to Use "Smart" Quotes in Your Documents
--------------------------------------------------------------

For one thing, you might not care.

Most normal, mentally stable individuals do not take notice of proper
typographic punctuation. Many design and typography nerds, however, break
out in a nasty rash when they encounter, say, a restaurant sign that uses
a straight apostrophe to spell "Joe's".

If you're the sort of person who just doesn't care, you might well want to
continue not caring. Using straight quotes -- and sticking to the 7-bit
ASCII character set in general -- is certainly a simpler way to live.

Even if you *do* care about accurate typography, you still might want to
think twice before "auto-educating" the quote characters in your documents.
As there is always a chance that the algorithm gets it wrong, you may
instead prefer to use the compose key or some other means to insert the
correct Unicode characters into the source.


Algorithmic Shortcomings
------------------------

The ASCII character (u0027 APOSTROPHE) is used for apostrophe and single
quotes. If used inside a word, it is converted into an apostrophe:

   .. class:: language-fr

   Il dit : "C'est 'super' !"

At the beginning or end of a word, it cannot be distinguished from a single
quote by the algorithm.

The `right single quotation mark`_ character -- used to close a secondary
(inner) quote in English -- is also "the preferred character to use for
apostrophe" (Unicode_). Therefore, "educating" works as expected for
apostrophes at the end of a word, e.g.,

  Mr. Hastings' pen; three days' leave; my two cents' worth.

However, when apostrophes are used at the start of leading contractions,
"educating" will turn the apostrophe into an *opening* secondary quote. In
English, this is *not* the apostrophe character, e.g., ``'Twas brillig``
is "miseducated" to

  'Twas brillig.

In other locales (French, Italian, German, ...), secondary closing quotes
differ from the apostrophe. A text like::

   .. class:: language-de-CH

   "Er sagt: 'Ich fass' es nicht.'"

becomes

   «Er sagt: ‹Ich fass› es nicht.›»

with a single closing guillemet in place of the apostrophe.

In such cases, it's best to use the recommended apostrophe character (’) in
the source:

   | ’Twas brillig, and the slithy toves
   | Did gyre and gimble in the wabe;
   | All mimsy were the borogoves,
   | And the mome raths outgrabe.

.. _right single quotation mark:
    http://www.fileformat.info/info/unicode/char/2019/index.htm
.. _Unicode: https://www.unicode.org/charts/PDF/U2000.pdf

History
=======

The smartquotes module is an adaption of "SmartyPants_" to Docutils.

`John Gruber`_ did all of the hard work of writing this software in Perl for
`Movable Type`_ and almost all of this useful documentation.  `Chad Miller`_
ported it to Python to use with Pyblosxom_.

Portions of the SmartyPants original work are based on Brad Choate's nifty
MTRegex plug-in.  `Brad Choate`_ also contributed a few bits of source code to
this plug-in.  Brad Choate is a fine hacker indeed.
`Jeremy Hedley`_ and `Charles Wiltgen`_ deserve mention for exemplary beta
testing of the original SmartyPants.

Internationalization and adaption to Docutils by Günter Milde.

.. _SmartyPants: http://daringfireball.net/projects/smartypants/
.. _Pyblosxom: http://pyblosxom.bluesock.org/
.. _Movable Type: http://www.movabletype.org/
.. _John Gruber: http://daringfireball.net/
.. _Chad Miller: http://web.chad.org/
.. _Brad Choate: http://bradchoate.com/
.. _Jeremy Hedley: http://antipixel.com/
.. _Charles Wiltgen: http://playbacktime.com/
.. _Rael Dornfest: http://raelity.org/