@@ -1647,6 +1647,7 @@ public function emitToken($token, $mode = null) {
1647
1647
1648
1648
if ($ category !==self ::PHRASING &&$ category !==self ::FORMATTING ) {
1649
1649
$ furthest_block =$ this ->stack [$ s ];
1650
+ break ;
1650
1651
}
1651
1652
}
1652
1653
@@ -1693,8 +1694,7 @@ public function emitToken($token, $mode = null) {
1693
1694
the stack of open elements and then go back
1694
1695
to step 1. */
1695
1696
if (!in_array ($ node ,$ this ->a_formatting ,true )) {
1696
- unset($ this ->stack [$ n ]);
1697
- $ this ->stack =array_merge ($ this ->stack );
1697
+ array_splice ($ this ->stack ,$ n ,1 );
1698
1698
1699
1699
}else {
1700
1700
break ;
@@ -1783,23 +1783,22 @@ public function emitToken($token, $mode = null) {
1783
1783
into the list of active formatting elements at the
1784
1784
position of the aforementioned bookmark. */
1785
1785
$ fe_af_pos =array_search ($ formatting_element ,$ this ->a_formatting ,true );
1786
- unset($ this ->a_formatting [$ fe_af_pos ]);
1787
- $ this ->a_formatting =array_merge ($ this ->a_formatting );
1786
+ array_splice ($ this ->a_formatting ,$ fe_af_pos ,1 );
1788
1787
1789
1788
$ af_part1 =array_slice ($ this ->a_formatting ,0 ,$ bookmark -1 );
1790
- $ af_part2 =array_slice ($ this ->a_formatting ,$ bookmark, count ( $ this -> a_formatting ) );
1789
+ $ af_part2 =array_slice ($ this ->a_formatting ,$ bookmark );
1791
1790
$ this ->a_formatting =array_merge ($ af_part1 ,array ($ clone ),$ af_part2 );
1792
1791
1793
1792
/* 12. Remove the formatting element from the stack
1794
1793
of open elements, and insert the new element into the stack
1795
1794
of open elements immediately below the position of the
1796
1795
furthest block in that stack. */
1797
1796
$ fe_s_pos =array_search ($ formatting_element ,$ this ->stack ,true );
1798
- $ fb_s_pos =array_search ($ furthest_block ,$ this ->stack ,true );
1799
- unset($ this ->stack [$ fe_s_pos ]);
1797
+ array_splice ($ this ->stack ,$ fe_s_pos ,1 );
1800
1798
1801
- $ s_part1 =array_slice ($ this ->stack ,0 ,$ fb_s_pos );
1802
- $ s_part2 =array_slice ($ this ->stack ,$ fb_s_pos +1 ,count ($ this ->stack ));
1799
+ $ fb_s_pos =array_search ($ furthest_block ,$ this ->stack ,true );
1800
+ $ s_part1 =array_slice ($ this ->stack ,0 ,$ fb_s_pos +1 );
1801
+ $ s_part2 =array_slice ($ this ->stack ,$ fb_s_pos +1 );
1803
1802
$ this ->stack =array_merge ($ s_part1 ,array ($ clone ),$ s_part2 );
1804
1803
1805
1804
/* 13. Jump back to step 1 in this series of steps. */