{"id":18380852,"url":"https://github.com/eeholmes/targets-bookdown","last_synced_at":"2026-01-22T07:02:20.649Z","repository":{"id":43735266,"uuid":"461229675","full_name":"eeholmes/targets-bookdown","owner":"eeholmes","description":"sandbox attempt at combining bookdown and targets","archived":false,"fork":false,"pushed_at":"2022-02-22T01:06:14.000Z","size":381,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T20:34:05.741Z","etag":null,"topics":["bookdown","bookdown-book","rmarkdown","targets"],"latest_commit_sha":null,"homepage":"https://eeholmes.github.io/targets-bookdown","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eeholmes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-19T15:20:50.000Z","updated_at":"2022-02-22T00:29:51.000Z","dependencies_parsed_at":"2022-08-22T11:20:25.321Z","dependency_job_id":null,"html_url":"https://github.com/eeholmes/targets-bookdown","commit_stats":null,"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/eeholmes/targets-bookdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeholmes%2Ftargets-bookdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeholmes%2Ftargets-bookdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeholmes%2Ftargets-bookdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeholmes%2Ftargets-bookdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eeholmes","download_url":"https://codeload.github.com/eeholmes/targets-bookdown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eeholmes%2Ftargets-bookdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28657544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bookdown","bookdown-book","rmarkdown","targets"],"created_at":"2024-11-06T00:43:47.144Z","updated_at":"2026-01-22T07:02:20.631Z","avatar_url":"https://github.com/eeholmes.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Targets + Bookdown\n\nI originally used the approach of https://github.com/robitalec/targets-parameterized-bookdown but with that approach **equations will not work**. This renders the chapters to markdown and equations (unless very simple) won't work. But a fairly simple tweak will allow it to work. Basically use `knitr::knit()` instead of `rmarkdown::render()` to create the rendered R Markdown files.\n\n**update** This doesn't work as it breaks all the figure legends from {bookdown}. It replaces images with `\u003cimg\u003e` html tags and that loses all the info that {bookdown} needs to make legends. I tried `rmarkdown::render()` with some {bookdown} output formats but couldn't figure out a what to get both the figure legends and refs plus the equations.\n\nThis gives an html fragment that can be included but lose all the heading (chapter, section) info.\n```\nrmarkdown::render(\"chap2.Rmd\", output_format = bookdown::html_fragment2(self_contained = FALSE))\n```\n\nThis is an attempt to use {targets} with {bookdown} to track the status of chapter and not re-render chapters each time the book needs to be rebuilt. At the book level, the dependencies are super simple, just checks if the chapter Rmd has changed. But for a specific chapter, you can have a separate {targets} pipeline that might be much more complex. {targets} [projects](https://books.ropensci.org/targets/projects.html) is probably a better way to go in that situation.\n\n*Why did I do this?* I have many big bookdown projects and re-building is always a bit of torture. The bookdown caching feature is quite buggy and crashes my R session all the time. Hopefully this works better.\n\n\n## To run the book\n\n* Install the {targets}, {tarchetypes} and {bookdown} packages\n* Type `tar_make()` at the command line.\n* Look in the `_book` folder for the `index.html` file and open that.\n\n## To add chapters\n\n* The chapters are in the `chapters` folder. Add an Rmd there.\n* Open the `_targets.R` file and add something like `target_factory(chap2)` but replace `chap2` with your file name.\n* `chapters/chap3` shows and example where the chapter uses targets markdown to create a chapter specific pipeline. To run, set `chapters/chap3` as the working directory, open `chap3.Rmd` and knit. Then \n\n## Explanations\n\n* `_targets.R` is setting up the targets objects so {targets} can keep track of when objects need to be updated (because a dependency changed)\n* `R/chapterfactory.R` is a file I wrote to create the chapter dependencies and objects. Basically it just renders a chapter Rmd and put the rendered version (md) into the folder `rendered-chapters` folder.\n* Use `tar_visnetworks()` to visualize the network and status.\n\n## Re-use statement\n\nPlease re-use however you want. No attribution needed.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeholmes%2Ftargets-bookdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feeholmes%2Ftargets-bookdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feeholmes%2Ftargets-bookdown/lists"}