noamross / redoc

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

Resolving changes/comments with the CriticMarkup syntax in Rmd files (if at all supported) #38

Open lcolladotor opened 5 years ago

lcolladotor commented 5 years ago

Hi Noam,

This issue is related to https://twitter.com/noamross/status/1129423451234668547.

Using redoc version 0.1.0.9000 and MS Word for Mac version 16.16.10 (190512), I found no way to accept or reject changes from the CriticMarkup syntax in an Rmd file. Maybe you would like users to interact with changes in the MS Word version, resolve them there, then use redoc::dedoc() once that's all done.

If you are interested in supporting a way to resolve changes, I would imagine that some type of browser-like viewer that is similar to interfaces for resolving git conflicts would be useful (choose option A --aka left--, option B --aka right-- or make your new option C).

There's also some of this functionality already in the CriticMarkup TextMate addin (which I then modified so it would work a bit with Rmd files) at https://github.com/lcolladotor/criticmarkup.tmbundle forked from https://github.com/DivineDominion/criticmarkup.tmbundle. The accept code basically is this one: https://github.com/lcolladotor/criticmarkup.tmbundle/blob/master/Support/bin/accept_critic.rb which is a series of gsub calls. I believe that it's not 100% complete for all the CriticMarkup syntax cases. These could be RStudio addins (similar to TextMate Bundle commands) and are likely easier to code than the git conflict-like interface. Though just stating in the documentation that users should resolve changes in the MS Word version could be ok too ^^.

Best, Leo

Session info

> library('redoc')
> options(width = 120)
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       macOS Mojave 10.14.4        
 system   x86_64, darwin15.6.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/New_York            
 date     2019-05-20                  

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version    date       lib source                             
 assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                     
 base64enc     0.1-3      2015-07-28 [1] CRAN (R 3.6.0)                     
 cli           1.1.0      2019-03-19 [1] CRAN (R 3.6.0)                     
 crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                     
 diffobj       0.2.2.9003 2019-05-17 [1] Github (brodieG/diffobj@5c9b288)   
 digest        0.6.18     2018-10-10 [1] CRAN (R 3.6.0)                     
 evaluate      0.13       2019-02-12 [1] CRAN (R 3.6.0)                     
 htmltools     0.3.6      2017-04-28 [1] CRAN (R 3.6.0)                     
 httr          1.4.0      2018-12-11 [1] CRAN (R 3.6.0)                     
 jsonlite      1.6        2018-12-07 [1] CRAN (R 3.6.0)                     
 knitr         1.22       2019-03-08 [1] CRAN (R 3.6.0)                     
 magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)                     
 mime          0.6        2018-10-05 [1] CRAN (R 3.6.0)                     
 officer       0.3.4      2019-05-17 [1] Github (davidgohel/officer@c1e1a57)
 R6            2.4.0      2019-02-14 [1] CRAN (R 3.6.0)                     
 Rcpp          1.0.1      2019-03-17 [1] CRAN (R 3.6.0)                     
 redoc       * 0.1.0.9000 2019-05-17 [1] Github (noamross/redoc@5e25471)    
 rlang         0.3.4      2019-04-07 [1] CRAN (R 3.6.0)                     
 rmarkdown     1.12       2019-03-14 [1] CRAN (R 3.6.0)                     
 sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                     
 stringi       1.4.3      2019-03-12 [1] CRAN (R 3.6.0)                     
 uuid          0.1-2      2015-07-28 [1] CRAN (R 3.6.0)                     
 whoami        1.3.0      2019-03-19 [1] CRAN (R 3.6.0)                     
 withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                     
 xfun          0.7        2019-05-14 [1] CRAN (R 3.6.0)                     
 xml2          1.2.0      2018-01-24 [1] CRAN (R 3.6.0)                     
 yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                     
 zip           2.0.2      2019-05-13 [1] CRAN (R 3.6.0)                     

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library
> 
noamross commented 5 years ago

Resolving changes in Word and then de-rendering is my preferred workflow, but I don't think it should be everyone's. I don't think resolving changes in the redoc_diff() view is likely, though. Instead, these should happen in the text editor. There's some ways to make this easier, tough.

1) Syntax highlighting in the editor. This actually requires a PR to RStudio to change this file to pick up CM syntax: https://github.com/rstudio/rstudio/blob/8af730409bb6d651cc8f6816d136bea91441e7a4/src/gwt/acesupport/acemode/markdown_highlight_rules.js . If they agree, then a theme could be included in this package to highlight those sections.

2) An RStudio add-in with keyboard-shortcuttable commands like "Accept", "Reject/Remove Comment", "Accept and move to next", "Reject/Remove Comment and move to next", "Accept all", "Reject all", "Resolve all comments." It could also include commands for creating CM markup.

I'll add these to the list, but both are definitely things I could use help with and aren't too in the weeds of the current code base, so happy to accept PRs.