diff --git a/example/a.txt b/example/a.txt index 6f3897b2..72561fac 100644 --- a/example/a.txt +++ b/example/a.txt @@ -4,6 +4,8 @@
Příliš žluťoučký kůň úpěl ďábelské ódy
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Příliš žluťoučký kůň úpěl ďábelské ódy -- previous sentence is a pangram for Czech language (see http://en.wikipedia.org/wiki/Pangram)
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
diff --git a/example/example.php b/example/example.php index 234bc2c8..d9eedbb7 100644 --- a/example/example.php +++ b/example/example.php @@ -22,6 +22,8 @@ $options = array( //'ignoreWhitespace' => true, //'ignoreCase' => true, + //'title_a' => 'some other title than "Old Version"', + //'title_b' => 'some other title than "New Version"', ); // Initialize the diff class diff --git a/lib/Diff.php b/lib/Diff.php index 35305c03..62805dc7 100644 --- a/lib/Diff.php +++ b/lib/Diff.php @@ -67,13 +67,16 @@ class Diff 'context' => 3, 'ignoreNewLines' => false, 'ignoreWhitespace' => false, - 'ignoreCase' => false + 'ignoreCase' => false, + 'title_a'=>'Old Version', + 'title_b'=>'New Version', + 'labelDifferences'=>'Differences' ); /** * @var array Array of the options that have been applied for generating the diff. */ - private $options = array(); + public $options = array(); /** * The constructor. @@ -170,7 +173,7 @@ public function getGroupedOpcodes() require_once dirname(__FILE__).'/Diff/SequenceMatcher.php'; $sequenceMatcher = new Diff_SequenceMatcher($this->a, $this->b, null, $this->options); - $this->groupedCodes = $sequenceMatcher->getGroupedOpcodes(); + $this->groupedCodes = $sequenceMatcher->getGroupedOpcodes($this->options['context']); return $this->groupedCodes; } } \ No newline at end of file diff --git a/lib/Diff/Renderer/Html/Inline.php b/lib/Diff/Renderer/Html/Inline.php index 60e8005a..28a1fe64 100644 --- a/lib/Diff/Renderer/Html/Inline.php +++ b/lib/Diff/Renderer/Html/Inline.php @@ -53,6 +53,10 @@ class Diff_Renderer_Html_Inline extends Diff_Renderer_Html_Array public function render() { $changes = parent::render(); + $title_a = $this->diff->options['title_a']; + $title_b = $this->diff->options['title_b']; + $label_differences = $this->diff->options['labelDifferences']; + $html = ''; if(empty($changes)) { return $html; @@ -61,9 +65,9 @@ public function render() $html .= 'Old | '; - $html .= 'New | '; - $html .= 'Differences | '; + $html .= ''.$title_a.' | '; + $html .= ''.$title_b.' | '; + $html .= ''.$label_differences.' | '; $html .= '||
---|---|---|---|---|---|---|---|
'.$toLine.' | '; $html .= ''; + $html .= ' | '.$toLine.' | '; $html .= ''.$line.' | '; $html .= '
Old Version | '; - $html .= 'New Version | '; + $html .= ''.$title_a.' | '; + $html .= ''.$title_b.' | '; $html .= '
---|