-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: SF Bug 190: highlight_lines_extra eats end-of-line
This applies the proposed fix from https://sourceforge.net/p/geshi/bugs/190/ Because of the lack of comprehensive tests, it's unclear if this has any side effects, but it does fix the reported problem. A test case for this bug in particular has been added.
- Loading branch information
1 parent
fd22ab7
commit 3c12a79
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Ensures the number of output lines are the same as the input | ||
*/ | ||
class NewlineTest extends TestCase | ||
{ | ||
|
||
/** | ||
* No fancy settings | ||
*/ | ||
public function testDefault() | ||
{ | ||
$input = <<< END | ||
void main () { | ||
printf ("Hello World"); | ||
exit 0; | ||
} | ||
END; | ||
$input_lines = count(explode("\n", $input)); | ||
|
||
$geshi = new GeSHi($input, 'c'); | ||
$geshi->highlight_lines_extra(2); | ||
$output = $geshi->parse_code(); | ||
$output_lines = count(explode("\n", $output)); | ||
|
||
$this->assertEquals($input_lines, $output_lines, "number of line mismatch between input and output"); | ||
} | ||
|
||
/** | ||
* Highlighting a line | ||
* | ||
* checks for SF bug 190 | ||
* | ||
* @link https://sourceforge.net/p/geshi/bugs/190/ | ||
*/ | ||
public function testHighlight() | ||
{ | ||
$input = <<< END | ||
void main () { | ||
printf ("Hello World"); | ||
exit 0; | ||
} | ||
END; | ||
$input_lines = count(explode("\n", $input)); | ||
|
||
$geshi = new GeSHi($input, 'c'); | ||
$geshi->highlight_lines_extra(2); | ||
$output = $geshi->parse_code(); | ||
$output_lines = count(explode("\n", $output)); | ||
|
||
$this->assertEquals($input_lines, $output_lines, "number of line mismatch between input and output"); | ||
} | ||
} |