The basic idea of the above hook function is that if the number of lines of the text output is greater than the threshold set in the chunk option out.lines
(stored in the variable n
in the function body), we only keep the first n
lines and add an ellipsis () to indicate the output is truncated.
And you see four lines of output as expected. Since we have stored the original output
hook in hook_output
, we can restore it by calling the method again:
Please note that the last line in the output (i.e., the argument x
of the hook function) might be an empty line, so you may need something like (+ 1
to take the last empty line into account).