Skip to content

Commit

Permalink
Include file and line numbers when rendering (Closes yihui#2232)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeehio committed Apr 25, 2023
1 parent 5ce5531 commit 71e4249
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,19 @@ process_file = function(text, output) {
labels = unlist(lapply(groups, function(g) {
if (is.list(g$params)) g[[c('params', 'label')]] else ''
}))
linenums <- unlist(lapply(seq_along(groups), function(i) {
curr_lines <- current_lines(i)
sprintf(
"%s:%d-%d",
knit_concord$get('infile'),
curr_lines[1],
curr_lines[2]
)
}))
labels_linenums <- paste(labels, linenums, sep = " @ ")
if (progress) {
pb_fun = getOption('knitr.progress.fun', txt_pb)
pb = if (is.function(pb_fun)) pb_fun(n, labels)
pb = if (is.function(pb_fun)) pb_fun(n, labels_linenums)
on.exit(if (!is.null(pb)) pb$done(), add = TRUE)
}
wd = getwd()
Expand Down

0 comments on commit 71e4249

Please sign in to comment.