Skip to content

Commit

Permalink
Add the display carriage_returns option
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Baker committed Feb 26, 2014
1 parent 53a8131 commit 8de7f15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions class.krumo.php
Expand Up @@ -1400,14 +1400,20 @@ private static function _string($data, $name)

// Get the truncate length from the config, or default to 100
$truncate_length = Krumo::_config('display', 'truncate_length', 100);
$display_cr = Krumo::_config('display', 'carriage_returns', true);

if (strLen($data) > $truncate_length ) {
$_ = substr($data, 0, $truncate_length - 1);
$_extra = true;
}

$_ = htmlentities($_);
$_ = preg_replace("/\\n/","<strong class=\"krumo-carrage-return\">\\n</strong>",$_);

if ($display_cr) {
$_ = preg_replace("/\\n/","<strong class=\"krumo-carrage-return\">\\n</strong>",$_);
} else {
$_ = nl2br($_);
}

$expand_class = '';
if ($_extra) { $expand_class = 'krumo-expand'; }
Expand Down Expand Up @@ -1443,7 +1449,12 @@ private static function _string($data, $name)

if ($_extra) {
$data = htmlentities($data);
$data = preg_replace("/\\n/","<strong class=\"krumo-carrage-return\">\\n</strong>",$data);

if ($display_cr) {
$data = preg_replace("/\\n/","<strong class=\"krumo-carrage-return\">\\n</strong>",$data);
} else {
$data = nl2br($data);
}

print "<div class=\"krumo-nest\" $collapse_style>";
print "<ul class=\"krumo-node\">";
Expand Down
4 changes: 4 additions & 0 deletions krumo.sample.ini
Expand Up @@ -37,6 +37,10 @@
;show_version = true
;show_call_info = true

; Display carraige returns inside of strings are a literal \n to make it easier to read
; If this is set to false, carriage returns will be changed to <br /> to display in HTML
carriage_returns = 0

[sorting]
; Krumo defaults to sorting associative arrays by their keys. This
; makes finding elements easier. If you want to see the original array
Expand Down

0 comments on commit 8de7f15

Please sign in to comment.