File tree 1 file changed +16
-13
lines changed
1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ def predicate_to_string( path, &block )
178
178
when :literal
179
179
path . shift
180
180
string << " "
181
- string << QuoteLiteral ( path . shift )
181
+ string << quote_literal ( path . shift )
182
182
string << " "
183
183
else
184
184
string << " "
@@ -188,6 +188,21 @@ def predicate_to_string( path, &block )
188
188
return string . squeeze ( " " )
189
189
end
190
190
191
+ def quote_literal ( literal )
192
+ case literal
193
+ when String
194
+ # XPath 1.0 does not support escape characters.
195
+ # Assumes literal does not contain both single and double quotes.
196
+ if literal . include? ( "'" )
197
+ "\" #{ literal } \" "
198
+ else
199
+ "'#{ literal } '"
200
+ end
201
+ else
202
+ literal . inspect
203
+ end
204
+ end
205
+
191
206
private
192
207
#LocationPath
193
208
# | RelativeLocationPath
@@ -363,18 +378,6 @@ def Predicate path, parsed
363
378
path
364
379
end
365
380
366
- def QuoteLiteral literal
367
- case literal
368
- when String
369
- # Xpath 1.0 does not support escape characters.
370
- # Assumes literal does not contain both single and double quotes.
371
- pattern = literal . include? ( '"' ) ? "'%s'" : '"%s"'
372
- pattern % literal
373
- else
374
- literal . inspect
375
- end
376
- end
377
-
378
381
# The following return arrays of true/false, a 1-1 mapping of the
379
382
# supplied nodeset, except for axe(), which returns a filtered
380
383
# nodeset
You can’t perform that action at this time.
0 commit comments