Word doc to bookdown work flow

I have a long word document that I would like to convert to a bs4 book with minimal manual editing.

I've come up with what I think is pretty reasonable for gitbook:

  1. Create an empty .rmd doc for gitbook
  2. Use pandoc to go from docx to markdown
  3. call the markdown file into the gitbook rmd file
  4. knit

This works pretty well (The word doc uses headers already) and the errors are minimal.

Howver, if I want to use bs4_book I believe I need to split the new .Rmd file into individual files for each "chapter." I there a way to automate this? For example, creating .Rmd files called 01-HEADER#1_text.Rmd, 02-HEADER#2.Rmd etc.. directly from the .md or .Rmd file?

thanks!

I believe you could do that by using R code.

Look at the fs :package: to manipulate files, and brio or function like xfun::read_utf8() to read the file content and split where your need. You can read them, get headers and split, write back to file with new name.

Something like this should help you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.