WordLevelDiff example

foreach ($lines as $line) {
      $this->rows[] = array_merge($this->contextLine(Html::escape($line))$this->contextLine(Html::escape($line)));
    }
  }

  /** * {@inheritdoc} */
  protected function _changed($orig$closing) {
    $orig = array_map('\Drupal\Component\Utility\Html::escape', $orig);
    $closing = array_map('\Drupal\Component\Utility\Html::escape', $closing);
    $diff = new WordLevelDiff($orig$closing);
    $del = $diff->orig();
    $add = $diff->closing();

    // Notice that WordLevelDiff returns HTML-escaped output. Hence, we will be     // calling addedLine/deletedLine without HTML-escaping.     while ($line = array_shift($del)) {
      $aline = array_shift($add);
      $this->rows[] = array_merge($this->deletedLine($line)isset($aline) ? $this->addedLine($aline) : $this->emptyLine());
    }

    // If any leftovers.
Home | Imprint | This part of the site doesn't use cookies.