- case self::COLON_STATE_TEXT:
- switch ( $c ) {
- case "<":
- # Could be either a <start> tag or an </end> tag
- $state = self::COLON_STATE_TAGSTART;
- break;
- case ":":
- if ( $ltLevel === 0 ) {
- # We found it!
- $before = substr( $str, 0, $i );
- $after = substr( $str, $i + 1 );
- return $i;
+ case self::COLON_STATE_TEXT:
+ switch ( $c ) {
+ case "<":
+ # Could be either a <start> tag or an </end> tag
+ $state = self::COLON_STATE_TAGSTART;
+ break;
+ case ":":
+ if ( $ltLevel === 0 ) {
+ # We found it!
+ $before = substr( $str, 0, $i );
+ $after = substr( $str, $i + 1 );
+ return $i;
+ }
+ # Embedded in a tag; don't break it.
+ break;
+ default:
+ # Skip ahead looking for something interesting
+ if ( !preg_match( '/:|<|-\{/', $str, $m, PREG_OFFSET_CAPTURE, $i ) ) {
+ # Nothing else interesting
+ return false;
+ }
+ if ( $m[0][0] === '-{' ) {
+ $state = self::COLON_STATE_LC;
+ $lcLevel++;
+ $i = $m[0][1] + 1;
+ } else {
+ # Skip ahead to next interesting character.
+ $i = $m[0][1] - 1;
+ }
+ break;