2 # -*- coding: utf-8 -*-
5 # :Copyright: © 2011 Günter Milde.
6 # :Maintainer: docutils-develop@lists.sourceforge.net
7 # :License: Released under the terms of the `2-Clause BSD license`_, in short:
9 # Copying and distribution of this file, with or without modification,
10 # are permitted in any medium without royalty provided the copyright
11 # notice and this notice are preserved.
12 # This file is offered as-is, without any warranty.
14 # .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
17 Test module for universal.SmartQuotes transform.
21 from __init__
import DocutilsTestSupport
# must be imported before docutils
22 from docutils
.transforms
.universal
import SmartQuotes
23 from docutils
.parsers
.rst
import Parser
27 settings
= {'smart_quotes': True}
28 s
= DocutilsTestSupport
.TransformTestSuite(
29 parser
, suite_settings
=settings
)
30 s
.generateTests(totest
)
31 settings
['language_code'] = 'de'
32 s
.generateTests(totest_de
)
33 settings
['smart_quotes'] = 'alternative'
34 s
.generateTests(totest_de_alt
)
42 totest
['transitions'] = ((SmartQuotes
,), [
44 Test "smart quotes", 'secondary smart quotes',
45 "'nested' smart" quotes
46 -- and ---also long--- dashes.
49 <document source="test data">
51 Test “smart quotes”, ‘secondary smart quotes’,
52 “‘nested’ smart” quotes
53 – and —also long— dashes.
55 [r
"""Escaped \\"smart quotes\\", \\'secondary smart quotes\\',
56 \\"\\'nested\\' smart\\" quotes
57 \\-- and -\\--also long-\\-- dashes.
60 <document source="test data">
62 Escaped "smart quotes", 'secondary smart quotes',
63 "'nested' smart" quotes
64 -- and ---also long--- dashes.
67 Do not "educate" quotes ``inside "literal" text`` and ::
71 Keep quotes straight in code and math:
72 :code:`print "hello"` :math:`1' 12"`.
84 <document source="test data">
86 Do not “educate” quotes
90 <literal_block xml:space="preserve">
93 Keep quotes straight in code and math:
94 <literal classes="code">
100 <literal_block classes="code" xml:space="preserve">
102 <math_block xml:space="preserve">
106 Quotes and inline-elements:
108 * Around "_`targets`", "*emphasized*" or "``literal``" text
109 and links to "targets_".
111 * Inside *"emphasized"* or other `inline "roles"`
113 Do not drop characters from intra-word inline markup like
114 *re*\ ``Structured``\ *Text*.
117 <document source="test data">
119 Quotes and inline-elements:
120 <bullet_list bullet="*">
124 <target ids="targets" names="targets">
134 <reference name="targets" refname="targets">
146 Do not drop characters from intra-word inline markup like
156 .. class:: language-de
158 German "smart quotes" and 'secondary smart quotes'.
160 .. class:: language-en-UK
162 British "quotes" use single and 'secondary quotes' double quote signs.
164 .. class:: language-foo
166 "Quoting style" for unknown languages is 'ASCII'.
168 .. class:: language-de-x-altquot
170 Alternative German "smart quotes" and 'secondary smart quotes'.
173 <document source="test data">
174 <paragraph classes="language-de">
175 German „smart quotes“ and ‚secondary smart quotes‘.
176 <paragraph classes="language-en-uk">
177 British ‘quotes’ use single and “secondary quotes” double quote signs.
178 <paragraph classes="language-foo">
179 "Quoting style" for unknown languages is 'ASCII'.
180 <paragraph classes="language-de-x-altquot">
181 Alternative German »smart quotes« and ›secondary smart quotes‹.
182 <system_message level="2" line="11" source="test data" type="WARNING">
184 No smart quotes defined for language "foo".
188 totest_de
['transitions'] = ((SmartQuotes
,), [
190 German "smart quotes" and 'secondary smart quotes'.
192 .. class:: language-en
194 English "smart quotes" and 'secondary smart quotes'.
197 <document source="test data">
199 German „smart quotes“ and ‚secondary smart quotes‘.
200 <paragraph classes="language-en">
201 English “smart quotes” and ‘secondary smart quotes’.
205 totest_de_alt
['transitions'] = ((SmartQuotes
,), [
207 Alternative German "smart quotes" and 'secondary smart quotes'.
209 In this case, the apostrophe isn't a closing secondary quote!
211 .. class:: language-en-UK
213 British "quotes" use single and 'secondary quotes' double quote signs
214 (there are no alternative quotes defined).
216 .. class:: language-ro
218 Romanian "smart quotes" and 'secondary' smart quotes.
221 <document source="test data">
223 Alternative German »smart quotes« and ›secondary smart quotes‹.
225 In this case, the apostrophe isn’t a closing secondary quote!
226 <paragraph classes="language-en-uk">
227 British ‘quotes’ use single and “secondary quotes” double quote signs
228 (there are no alternative quotes defined).
229 <paragraph classes="language-ro">
230 Romanian „smart quotes” and «secondary» smart quotes.
234 if __name__
== '__main__':
236 unittest
.main(defaultTest
='suite')