@@ -122,6 +122,60 @@ def test_simple_file(self):
122
122
self .assertEqual (openstring .string , translation )
123
123
self .assertEqual (openstring .string , openstring .key )
124
124
125
+ def test_space_control (self ):
126
+ path = '{}/special_cases_2.docx' .format (self .TESTFILE_BASE )
127
+ with open (path , 'rb' ) as f :
128
+ content = f .read ()
129
+
130
+ handler = DocxHandler ()
131
+ template , stringset = handler .parse (content )
132
+
133
+ self .assertEqual (len (stringset ), 1 )
134
+
135
+ openstring = stringset [0 ]
136
+ self .assertEqual (openstring .order , 0 )
137
+ self .assertEqual (
138
+ openstring .string ,
139
+ u'one two <tx href="https://www.transifex.com/">three </tx><tx> four </tx>five' # noqa
140
+ )
141
+ self .assertEqual (openstring .string , openstring .key )
142
+
143
+ translation = u'ενα δύο <tx href="https://www.transifex.com/">τρία </tx><tx> τέσσερα </tx>πέντε' # noqa
144
+ stringset = [
145
+ OpenString (openstring .key , translation , order = 1 )
146
+ ]
147
+
148
+ content = handler .compile (template , stringset )
149
+ template , stringset = handler .parse (content )
150
+
151
+ self .assertEqual (len (stringset ), 1 )
152
+
153
+ openstring = stringset [0 ]
154
+ self .assertEqual (openstring .order , 0 )
155
+ self .assertEqual (
156
+ openstring .string ,
157
+ u'ενα δύο <tx href="https://www.transifex.com/">τρία </tx><tx> τέσσερα </tx>πέντε'
158
+ )
159
+ self .assertEqual (openstring .string , openstring .key )
160
+
161
+ translation = u'ενα δύο<tx href="https://www.transifex.com/">τρία</tx><tx>τέσσερα</tx>πέντε' # noqa
162
+ stringset = [
163
+ OpenString (openstring .key , translation , order = 1 )
164
+ ]
165
+
166
+ content = handler .compile (template , stringset )
167
+ template , stringset = handler .parse (content )
168
+
169
+ self .assertEqual (len (stringset ), 1 )
170
+
171
+ openstring = stringset [0 ]
172
+ self .assertEqual (openstring .order , 0 )
173
+ self .assertEqual (
174
+ openstring .string ,
175
+ u'ενα δύο<tx href="https://www.transifex.com/">τρία</tx><tx>τέσσερα</tx>πέντε'
176
+ )
177
+ self .assertEqual (openstring .string , openstring .key )
178
+
125
179
def test_hyperlink_reorder (self ):
126
180
path = '{}/special_cases_2.docx' .format (self .TESTFILE_BASE )
127
181
with open (path , 'rb' ) as f :
@@ -166,8 +220,6 @@ def test_hyperlink_reorder(self):
166
220
self .assertEqual (text_elements [1 ].parent .rPr .color , None )
167
221
self .assertEqual (text_elements [1 ].parent .rPr .u , None )
168
222
169
-
170
-
171
223
def test_complex_file (self ):
172
224
path = '{}/complex.docx' .format (self .TESTFILE_BASE )
173
225
with open (path , 'rb' ) as f :
0 commit comments