TYPO3  7.6
Html.php
Go to the documentation of this file.
1 <?php
2 
19 namespace cogpowered\FineDiff\Render;
20 
21 use cogpowered\FineDiff\Parser\OpcodeInterface;
22 
23 class Html extends Renderer
24 {
25  public function callback($opcode, $from, $from_offset, $from_len)
26  {
27  if ($opcode === 'c') {
28  $html = htmlentities(substr($from, $from_offset, $from_len));
29  } else if ($opcode === 'd') {
30 
31  $deletion = substr($from, $from_offset, $from_len);
32 
33  if (strcspn($deletion, " \n\r") === 0) {
34  $deletion = str_replace(array("\n","\r"), array('\n','\r'), $deletion);
35  }
36 
37  $html = '<del>'.htmlentities($deletion).'</del>';
38 
39  } else /* if ( $opcode === 'i' ) */ {
40  $html = '<ins>'.htmlentities(substr($from, $from_offset, $from_len)).'</ins>';
41  }
42 
43  return $html;
44  }
45 }