@@ -265,7 +265,7 @@ def scan_tokens encoder, options
265
265
@html_scanner . tokenize match unless match . empty?
266
266
end
267
267
268
- when :php
268
+ when :php , :php_inline
269
269
if match = scan ( /\s +/ )
270
270
encoder . text_token match , :space
271
271
@@ -332,14 +332,15 @@ def scan_tokens encoder, options
332
332
if states . size == 1
333
333
encoder . text_token match , :error
334
334
else
335
- states . pop
335
+ state = states . pop
336
336
if states . last . is_a? ( ::Array )
337
337
delimiter = states . last [ 1 ]
338
338
states [ -1 ] = states . last [ 0 ]
339
339
encoder . text_token match , :delimiter
340
340
encoder . end_group :inline
341
341
else
342
342
encoder . text_token match , :operator
343
+ encoder . end_group :inline if state == :php_inline
343
344
label_expected = true
344
345
end
345
346
end
@@ -350,7 +351,14 @@ def scan_tokens encoder, options
350
351
351
352
elsif match = scan ( RE ::PHP_END )
352
353
encoder . text_token match , :inline_delimiter
353
- states = [ :initial ]
354
+ while state = states . pop
355
+ encoder . end_group :string if [ :sqstring , :dqstring ] . include? state
356
+ if state . is_a? Array
357
+ encoder . end_group :inline
358
+ encoder . end_group :string if [ :sqstring , :dqstring ] . include? state . first
359
+ end
360
+ end
361
+ states << :initial
354
362
355
363
elsif match = scan ( /<<<(?:(#{ RE ::IDENTIFIER } )|"(#{ RE ::IDENTIFIER } )"|'(#{ RE ::IDENTIFIER } )')/o )
356
364
encoder . begin_group :string
@@ -400,6 +408,7 @@ def scan_tokens encoder, options
400
408
elsif match = scan ( /\\ / )
401
409
encoder . text_token match , :error
402
410
else
411
+ encoder . end_group :string
403
412
states . pop
404
413
end
405
414
@@ -459,7 +468,7 @@ def scan_tokens encoder, options
459
468
encoder . begin_group :inline
460
469
states [ -1 ] = [ states . last , delimiter ]
461
470
delimiter = nil
462
- states . push :php
471
+ states . push :php_inline
463
472
encoder . text_token match , :delimiter
464
473
else
465
474
encoder . text_token match , :content
@@ -469,6 +478,7 @@ def scan_tokens encoder, options
469
478
elsif match = scan ( /\$ / )
470
479
encoder . text_token match , :content
471
480
else
481
+ encoder . end_group :string
472
482
states . pop
473
483
end
474
484
@@ -502,6 +512,10 @@ def scan_tokens encoder, options
502
512
503
513
while state = states . pop
504
514
encoder . end_group :string if [ :sqstring , :dqstring ] . include? state
515
+ if state . is_a? Array
516
+ encoder . end_group :inline
517
+ encoder . end_group :string if [ :sqstring , :dqstring ] . include? state . first
518
+ end
505
519
end
506
520
507
521
encoder
0 commit comments