noamross / redoc

[NOTE: Project in suspended animation for now] Reversible Reproducible Documents
https://noamross.github.io/redoc
Other
514 stars 44 forks source link

Support of other formats: papaja, rdocx_document, word_document2 #34

Open noamross opened 5 years ago

noamross commented 5 years ago

There should be a way to use redoc with other formats based off of rmarkdown::word_document, such as those in the papaja, officedown, and bookdown packages. I see three possibilities:

1) We make versions of these output formats in the redoc package. This is the easiest to control, but they will rely on internal functions from those other packages, which will require those packages to be changed to export functions.

2) Make changes to those other packages to base their formats on redoc::redoc. Easiest for me, as others need to do it! I could write a vignette on how to develop an output format using redoc. Essentially one just needs to be careful about ordering to ensure no clashes between various pre- and post-processors, and then write appropriate code-capture wrappers if one needs them for new markup. We could PR these into those packages, of course.

3) Write a wrapper function, like redoc_render(), which renders and word-based format as a redoc. This would be convenient but is the most fragile approach, I think, and it would break things like the RStudio "knit" button and other code based on the rmarkdown::render() function.

Thoughts, @davidgohel, @yihui, @crsh?

crsh commented 5 years ago

Hi @noamross, thanks for starting this conversation. I'm very interested in solving this problem for papaja documents, so I'm willing to pitch in.

papaja::apa6_docx builds on bookdown::word_document2. I think it may be worth to keep these kinds of dependencies in mind, when thinking about this.

While (1.) may be easiest for me, I think (2.) will be more flexible with respect to new formats. A downside of (2.) that gives me pause are the added dependencies that this would add to papaja. Then again, I could probably create a second Word format and add redoc to suggests rather than imports.

Two questions about implementation:

  1. In my preprocessor, I add several things to the title page based on variables set in the YAML front matter. Is there a way to redoc such elements on the way back?
  2. I haven't had a chance to look more closely, but from what I was able to make out, I think you implemented a CriticMarkup translator for Word. I try to keep my Word- and PDF-formats compatible, so I'm wondering whether you are aware of a light-weight approach to render CriticMarkup to LaTeX (e.g., pancritic requires Python, if I understand correctly). If not, do you think it's feasible to turn such translators into Lua-filters?
noamross commented 5 years ago

@crsh Great to hear. I like (2) best, too, and think making dependencies optional is the right way to go. It'll take a couple of weeks before I dig into these things, but I wanted to capture the post-conference feedback.

1) I think so, but it may mean that dedoc() will require some format-specific methods. The standard metadata (title, subtitle, author, date), are all wrapped in specific word styles so pandoc can recapture them. For custom fields, we'll want to wrap them in custom styles on rendering, and then capture them in the reverse lua filter as metadata. This how all of redoc's machinery works - custom styles in Word basically act as classes and ids for stretches of text.

2) Yes, this step in R (https://github.com/noamross/redoc/blob/master/R/criticmarkup.R) converts CriticMarkup to Pandoc's internal representation of edits. Pandoc converts these to Word tracked changes natively when exporting to docx, but it should be straightforward to write a lua filter to do the same for LaTeX.

yihui commented 5 years ago

I don't fully understand the magic of redoc so I don't know what I'll need to do specifically, but I'll be happy to do my best to support you. I don't mind adding redoc to Suggests of bookdown to make bookdown::word_document2 work with redoc.

crsh commented 5 years ago

Hi @noamross, just checking in what the status of things is. Is there anything I can do at this point? I'm getting lots of feedback that the lack of redoc-style collaboration is a major road block for psychologists looking to move towards rmarkdown-based scientific writing.

tcgriffith commented 4 years ago

Wow, papaja+redoc is really happening! This must be Christmas!

davidrast3 commented 4 years ago

Is papaja + redoc implemented in the dev branch? I ran redoc on a manuscript created with papaja. I received a number of error messages (e.g., "We're sorry. We can't open XYZ.docx because we found a problem with its contents. Details: No error detail available"; "Word found unreadable content in XYZ.docx"). And, the docx file is most definitely not APA format.

MattCowgill commented 4 years ago

Is this still being considered for redoc?

noamross commented 4 years ago

Yes, sorry it has been a long while since I've been able to put time into redoc development. I'm going to put together a road map in the new year to try to get it moving again. Priorities will probably be (1) bug-fixing to CRAN-readiness, (2) papaja and similar integration, and I'll try to set up specific issues so I can efficiently solicit some help 🙏 .

MattCowgill commented 4 years ago

Great, thank you @noamross! I love redoc and I’m keen to contribute a PR or two if I can

jooyoungseo commented 4 years ago

I think this has to do with #56 on some level.

Since papaja::apa6_docx and papaja::apa6_word are based on bookdown::word_document2, resolving #56 will give a smoother transition.