Prepend title comments to each chunks. By default, title is the name of the corresponding chunk engines.
hook_title_comment( trigger = "title", default = "{engine}", args = list(), .set = TRUE )
trigger | A name of chunk option triggers the hook. |
---|---|
default | A string or function as a default value of the |
args | A list of arguments given to |
.set |
|
# Set hook which comments engine names of each chunks at the beginning. hook_title_comment() # Customize format # For R chunks, let title comment be something like "chunk-label.R". # Otherwise, fall back to the default behavior. hook_title_comment( default = function(options) { if (options$engine == "R") { return(sprintf("# %s.%s", options$label, options$engine)) } return(comment_title(options, template = "{engine}")) } )