Пример #1
0
 /**
  * This will produce a color-marked-up diff output in HTML from the input strings.
  *
  * @param string $str1 String 1
  * @param string $str2 String 2
  * @return string Formatted output.
  */
 public function makeDiffDisplay($str1, $str2)
 {
     if ($this->stripTags) {
         $str1 = strip_tags($str1);
         $str2 = strip_tags($str2);
     }
     $diff = new Diff();
     return $diff->render($str1, $str2);
 }
Пример #2
0
 public function diff(Twig_Environment $environment, Terms $terms, Terms $with_terms)
 {
     $view_name = $this->getTermsViewName();
     $terms_content = $environment->render($view_name, array('root' => $terms->getRoot()));
     $with_terms_content = $environment->render($view_name, array('root' => $with_terms->getRoot()));
     $granularity = new Sentence();
     $diff = new Diff($granularity);
     return html_entity_decode($diff->render($terms_content, $with_terms_content, $granularity));
 }
 public function testRender()
 {
     $opcodes = m::mock('cogpowered\\FineDiff\\Parser\\Opcodes');
     $opcodes->shouldReceive('generate')->andReturn('c12');
     $parser = m::mock('cogpowered\\FineDiff\\Parser\\Parser');
     $parser->shouldReceive('parse')->andReturn($opcodes);
     $html = m::mock('cogpowered\\FineDiff\\Render\\Html');
     $html->shouldReceive('process')->with('hello', $opcodes)->once();
     $diff = new Diff(null, $html, $parser);
     $diff->render('hello', 'hello2');
 }
 public function testInsertParagraphGranularity()
 {
     list($from, $to, $opcodes, $html) = $this->getFile('paragraph/simple');
     $diff = new Diff(new Paragraph());
     $generated_opcodes = $diff->getOpcodes($from, $to);
     // Generate opcodes
     $this->assertEquals($generated_opcodes, $opcodes);
     // Render to text from opcodes
     $render = new Text();
     $this->assertEquals($render->process($from, $generated_opcodes), $to);
     // Render to html from opcodes
     $render = new Html();
     $this->assertEquals($render->process($from, $generated_opcodes), $html);
     // Render
     $this->assertEquals($diff->render($from, $to), $html);
 }