Filter knitr output by line indices
set_filter_output.RdSets a custom knitr output hook that filters printed output, keeping only
the lines specified in the chunk option lines. This is useful when
you want to show only selected parts of console output in knitted documents.
Details
The function modifies knitr's global output hook. Call it once (e.g., in a setup chunk) to activate the behavior for the rest of the document.
The hook:
splits the output into lines using
xfun::split_lines()selects lines via an internal helper
filor:::.grep_lines()passes the filtered output to the original knitr output hook