Skip to content
This repository has been archived by the owner on Feb 12, 2020. It is now read-only.

Commit

Permalink
Bug if only one range
Browse files Browse the repository at this point in the history
  • Loading branch information
crazy-max committed Jun 12, 2016
1 parent d3ea94d commit 7bbb8ff
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions syntaxhighlighter3/syntax/syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,22 @@ public function render($mode, &$renderer, $data) {
$highlight_str = str_replace(array('[', ']'), '', $highlight_str);
// Process ranges if exists
$highlight_exp = explode(',', $highlight_str);
if (count($highlight_exp) > 1) {
foreach ($highlight_exp as $highlight_elt) {
if (!empty($highlight)) {
$highlight .= ',';
}
$highlight_elt = trim($highlight_elt);
$highlight_elt_exp = explode('-', $highlight_elt);
if (count($highlight_elt_exp) == 2) {
foreach (range($highlight_elt_exp[0], $highlight_elt_exp[1]) as $key => $lineNumber) {
if ($key > 0) {
$highlight .= ',';
}
$highlight .= $lineNumber;
foreach ($highlight_exp as $highlight_elt) {
if (!empty($highlight)) {
$highlight .= ',';
}
$highlight_elt = trim($highlight_elt);
$highlight_elt_exp = explode('-', $highlight_elt);
if (count($highlight_elt_exp) == 2) {
foreach (range($highlight_elt_exp[0], $highlight_elt_exp[1]) as $key => $lineNumber) {
if ($key > 0) {
$highlight .= ',';
}
} else {
$highlight .= $highlight_elt;
$highlight .= $lineNumber;
}
} else {
$highlight .= $highlight_elt;
}
} else {
$highlight = trim($highlight_str);
}
$highlight = ' highlight: [' . $highlight . ']';
}
Expand Down

0 comments on commit 7bbb8ff

Please sign in to comment.