You are here

function DrupalDiffInline::process_chunk in Diff 6.2

Same name and namespace in other branches
  1. 7.3 DiffEngine.php \DrupalDiffInline::process_chunk()
  2. 7.2 DiffEngine.php \DrupalDiffInline::process_chunk()

Merge chunk segments between tag delimiters.

1 call to DrupalDiffInline::process_chunk()
DrupalDiffInline::render in ./DiffEngine.php
Render differences inline using HTML markup.

File

./DiffEngine.php, line 1269
A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)

Class

DrupalDiffInline
Drupal inline Diff formatter. @private @subpackage DifferenceEngine

Code

function process_chunk($chunk) {
  $processed = array();
  $j = 0;
  foreach ($chunk as $i => $piece) {
    $next = isset($chunk[$i + 1]) ? $chunk[$i + 1] : NULL;
    if (strpos($piece, '<') === 0 && substr($piece, strlen($piece) - 1) === '>') {
      $processed[$j] = $piece;
      $j++;
    }
    else {
      if (isset($next) && strpos($next, '<') === 0 && substr($next, strlen($next) - 1) === '>') {
        $processed[$j] .= $piece;
        $j++;
      }
      else {
        $processed[$j] .= $piece;
      }
    }
  }
  return $processed;
}