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", 'single smart quotes',
45 "'nested' smart" quotes
46 -- and ---also long--- dashes.
49 <document source="test data">
51 Test “smart quotes”, ‘single smart quotes’,
52 “‘nested’ smart” quotes
53 – and —also long— dashes.
56 Do not "educate" quotes ``inside "literal" text`` and ::
60 Keep quotes straight in code and math:
61 :code:`print "hello"` :math:`1' 12"`.
73 <document source="test data">
75 Do not “educate” quotes
79 <literal_block xml:space="preserve">
82 Keep quotes straight in code and math:
83 <literal classes="code">
89 <literal_block classes="code" xml:space="preserve">
91 <math_block xml:space="preserve">
95 Quotes and inline-elements:
97 * Around "_`targets`", "*emphasized*" or "``literal``" text
98 and links to "targets_".
100 * Inside *"emphasized"* or other `inline "roles"`
102 Do not drop characters from intra-word inline markup like
103 *re*\ ``Structured``\ *Text*.
106 <document source="test data">
108 Quotes and inline-elements:
109 <bullet_list bullet="*">
113 <target ids="targets" names="targets">
123 <reference name="targets" refname="targets">
135 Do not drop characters from intra-word inline markup like
145 .. class:: language-de
147 German "smart quotes" and 'single smart quotes'.
149 .. class:: language-foo
151 "Quoting style" for unknown languages is 'ASCII'.
153 .. class:: language-de-x-altquot
155 Alternative German "smart quotes" and 'single smart quotes'.
158 <document source="test data">
159 <paragraph classes="language-de">
160 German „smart quotes“ and ‚single smart quotes‘.
161 <paragraph classes="language-foo">
162 "Quoting style" for unknown languages is 'ASCII'.
163 <paragraph classes="language-de-x-altquot">
164 Alternative German »smart quotes« and ›single smart quotes‹.
165 <system_message level="2" line="7" source="test data" type="WARNING">
167 No smart quotes defined for language "foo".
171 totest_de
['transitions'] = ((SmartQuotes
,), [
173 German "smart quotes" and 'single smart quotes'.
175 .. class:: language-en-UK
177 English "smart quotes" and 'single smart quotes'.
180 <document source="test data">
182 German „smart quotes“ and ‚single smart quotes‘.
183 <paragraph classes="language-en-uk">
184 English “smart quotes” and ‘single smart quotes’.
188 totest_de_alt
['transitions'] = ((SmartQuotes
,), [
190 Alternative German "smart quotes" and 'single smart quotes'.
192 .. class:: language-en-UK
194 English "smart quotes" and 'single smart quotes' have no alternative.
196 .. class:: language-ro
198 Alternative Romanian "smart quotes" and 'single' smart quotes.
201 <document source="test data">
203 Alternative German »smart quotes« and ›single smart quotes‹.
204 <paragraph classes="language-en-uk">
205 English “smart quotes” and ‘single smart quotes’ have no alternative.
206 <paragraph classes="language-ro">
207 Alternative Romanian «smart quotes» and „single” smart quotes.
211 if __name__
== '__main__':
213 unittest
.main(defaultTest
='suite')