I use bookdown with the gitbook ouput to build a book. The .Rmd files used to build this book are in turn auto-generated from other source files in the following workflow: An R-Script takes folder1/file.txt and generates the file folder2/file.Rmd, which is in turn used to build the book.
So far, so good. However, when I use the edit option in _bookdown.yaml the link (naturally) refers to folder2/file.Rmd. It would be a simple thing to replace folder2 with folder1 and .Rmd with .txt, but I don't know where I should start.
In R/html.R (in the bookdown package), the link is generated within the function build_chapter using rmd_cur as input (which is "The Rmd filename of the current chapter") and the function source_link.
source_link = function(target, type) {
if (length(target) == 0) return()
setting = source_link_setting(type = type)
if (is.null(setting)) return()
button_link(sprintf(setting$link, target), setting$text)
}
How can I use this information to generate my custom link that points to folder1/file.txt instead of folder2/file.Rmd?
If you want the history and view to also link to the text file
otherwise overload the
build_chapterfunction: