Its Markdown output will be:
Then the text output block will be converted to HTML by Pandoc:
The attr.source
and options have made it possible for us to specify maximum heights for individual code chunks. However, the syntax is a little clunky, and requires a better understanding of CSS and Pandoc’s Markdown syntax. Below we show an example of a custom output
hook that works with a custom chunk option max.height
, so you will only need to set the chunk option like max.height = "100px"
instead of attr.output = 'style="max-height: 100px;"'
. In this example, we only manipulate the argument, but not the x
argument.
Figure shows the output. Note that in the last code chunk with the chunk option attr.output
, the option will not be overridden by max.height
because we respect existing attributes by combining them with the style
attribute generated by :
FIGURE 12.1: An example of scrollable text output, with its height specified in the chunk option max.height.
You can use a similar trick in the source
hook to limit the height of source code blocks.