kint-php / kint

Kint - Advanced PHP dumper
https://kint-php.github.io/kint/
MIT License
2.78k stars 292 forks source link

Add a truly HTML-free option to s(d)'s output #227

Closed SeinopSys closed 7 years ago

SeinopSys commented 7 years ago

In the "Advanced usage" section of the "Installation & usage" guide, there's this sentence:

The output is whitespace-formatted and uses no HTML/CSS/JS.

This is definitely not the case. When I call sd($data) I get an output like this:

<style>.-kint i{color:#d00;font-style:normal}.-kint u{color:#030;text-decoration:none;font-weight:bold}</style><pre class="-kint">┌──────────────────────────────────────────────────────────────────────────────┐
│                                    $data                                     │
└──────────────────────────────────────────────────────────────────────────────┘
array (5) [
    'key1' => integer 1
    'key2' => string (7) "abcdefg"
    'key3' => string (5) "right"
    'key4' => string (20) "https://example.com/"
    'key5' => string (29) "https://example.com/image.png"
]
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Called from <a href="">.../file.php.php:2</a>
</pre>

The additional CSS and HTML makes the dump output look strange when it's displayed raw inside a container with a limited size (e.g. a console window or a small HTML element), for example:

r1uy4coguegciugs_full 1

I'd like to ask for a setting/parameter that would produce the same output but without any added HTML/CSS.

jnvsor commented 7 years ago

The output is whitespace-formatted and uses no HTML/CSS/JS.

That's probably not the most accurate statement in the readme. There is a pure whitespace mode but it's not the same as plain mode which is being described there.

You can use the ~ modifier or set the mode to whitespace:

~d($x); // Pure whitespace mode
~s($x); // Ditto

Kint::enabled(Kint::MODE_WHITESPACE);
d($x); // Ditto
s($x); // Ditto
SeinopSys commented 7 years ago

Thank you! Although, that character should be added to the "Available modifiers" list - I would not have found it if it wasn't for your reply.