diff --git a/core/lib/Drupal/Component/Diff/DiffEngine.php b/core/lib/Drupal/Component/Diff/DiffEngine.php index 5be8a9d..7f95d2c 100644 --- a/core/lib/Drupal/Component/Diff/DiffEngine.php +++ b/core/lib/Drupal/Component/Diff/DiffEngine.php @@ -1229,7 +1229,7 @@ function _changed($orig, $closing) { * @private * @subpackage DifferenceEngine */ -class DrupalDiffInline { +abstract class DrupalDiffInline { var $a; var $b; @@ -1243,55 +1243,11 @@ function __construct($a, $b) { /** * Render differences inline using HTML markup. + * + * @return string + * Returns the rendered output of the HTML markup. */ - function render() { - $a = preg_split('/(<[^>]+?>| )/', $this->a, -1, PREG_SPLIT_DELIM_CAPTURE); - $b = preg_split('/(<[^>]+?>| )/', $this->b, -1, PREG_SPLIT_DELIM_CAPTURE); - $diff = new Diff($a, $b); - $diff->edits = $this->process_edits($diff->edits); - - // Assemble highlighted output - $output = ''; - foreach ($diff->edits as $chunk) { - switch ($chunk->type) { - case 'copy': - $output .= implode('', $chunk->closing); - break; - case 'delete': - foreach ($chunk->orig as $i => $piece) { - if (strpos($piece, '<') === 0 && Unicode::substr($piece, Unicode::strlen($piece) - 1) === '>') { - $output .= $piece; - } - else { - $diff_inline_chunk = array( - '#theme' => 'diff_inline_chunk', - '#text' => $piece, - '#type' => $chunk->type, - ); - $output .= drupal_render($diff_inline_chunk); - } - } - break; - default: - $chunk->closing = $this->process_chunk($chunk->closing); - foreach ($chunk->closing as $i => $piece) { - if ($piece === ' ' || (strpos($piece, '<') === 0 && Unicode::substr($piece, Unicode::strlen($piece) - 1) === '>' && Unicode::strtolower(Unicode::substr($piece, 1, 3)) != 'img')) { - $output .= $piece; - } - else { - $diff_inline_chunk = array( - '#theme' => 'diff_inline_chunk', - '#text' => $piece, - '#type' => $chunk->type, - ); - $output .= drupal_render($diff_inline_chunk); - } - } - break; - } - } - return $output; - } + abstract public function render(); /** * Merge chunk segments between tag delimiters.