Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new citeproc from Pandoc 2.11 #1916

Merged
merged 20 commits into from
Oct 12, 2020
Merged

Support new citeproc from Pandoc 2.11 #1916

merged 20 commits into from
Oct 12, 2020

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Oct 12, 2020

This will close #1915

@jjallaire
Copy link
Member

I don't think this full closes #1915 w/o dealing w/ the pandoc_citeproc_convert() function.

@cderv
Copy link
Collaborator Author

cderv commented Oct 12, 2020

Oh yes I know. This is why this is still a draft. Not yet ready to merge. I opened this draft PR to share the work and discuss if necessary.

I should have wrote a little something to comment further...

…oes not exist, but it didn't because we only checked the existence of the rmarkdown/lua folder, then we used file.path() to construct the paths, which doesn't check for the existence of files
@jjallaire
Copy link
Member

Okay sorry about the itchy GH comment finger....didn't see that is was marked draft!

@cderv
Copy link
Collaborator Author

cderv commented Oct 12, 2020

@JJ following your comment, #1915 (comment):

The manual included in the release bundle (not yet updated on website) give the infos:

Note that pandoc can be used to produce such a YAML metadata section from a BibTeX, BibLaTeX, or CSL JSON bibliography:

pandoc chem.bib -s -t markdown
pandoc chem.json -s -t markdown

pandoc can also be used to produce CSL JSON bibliography from BibTeX, BibLaTeX, or markdown YAML:

pandoc chem.bib -s -t csljson
pandoc chem.yaml -s -t csljson

Running pandoc on a bibliography file with the --citeproc option will create a formatted bibliography in the format of your choice:

pandoc chem.bib -s --citeproc -o chem.html
pandoc chem.bib -s --citeproc -o chem.pdf

There are some differences between the output when converted to YAML:

  • a nocite filed is added
  • There is no more spaces between fields in the new output
  • Oddly, pandoc-citeproc will add a ... at the end of the yaml part. pandoc will add a closing --- - that seems more correct.
  • Some fields are not the same. (see issued below for example)
# using this PR
# remotes::install_github("rstudio/rmarkdown#1916")
temp_bib <- tempfile(fileext = ".bib")
knitr::write_bib("bookdown", temp_bib)
#> Warning in utils::citation(..., lib.loc = lib.loc): no date field in DESCRIPTION
#> file of package 'bookdown'
#> Warning in utils::citation(..., lib.loc = lib.loc): could not determine year for
#> 'bookdown' from package DESCRIPTION file
rmarkdown::find_pandoc(cache = FALSE)
#> $version
#> [1] '2.9.2.1'
#> 
#> $dir
#> [1] "C:/Users/chris/scoop/apps/rstudio-daily/current/bin/pandoc"
rmarkdown::pandoc_citeproc_convert(temp_bib, type = "yaml")
#>  [1] "---"                                                                         
#>  [2] "references:"                                                                 
#>  [3] "- id: R-bookdown"                                                            
#>  [4] "  type: book"                                                                
#>  [5] "  author:"                                                                   
#>  [6] "  - family: Xie"                                                             
#>  [7] "    given: Yihui"                                                            
#>  [8] "  issued:"                                                                   
#>  [9] "  - year: 2020"                                                              
#> [10] "  title: 'Bookdown: Authoring books and technical documents with r markdown'"
#> [11] "  title-short: Bookdown"                                                     
#> [12] "  note: R package version 0.20.6"                                            
#> [13] "  URL: https://github.com/rstudio/bookdown"                                  
#> [14] ""                                                                            
#> [15] "- id: bookdown2016"                                                          
#> [16] "  type: book"                                                                
#> [17] "  author:"                                                                   
#> [18] "  - family: Xie"                                                             
#> [19] "    given: Yihui"                                                            
#> [20] "  issued:"                                                                   
#> [21] "  - year: 2016"                                                              
#> [22] "  title: 'Bookdown: Authoring books and technical documents with R markdown'"
#> [23] "  title-short: Bookdown"                                                     
#> [24] "  publisher: Chapman; Hall/CRC"                                              
#> [25] "  publisher-place: Boca Raton, Florida"                                      
#> [26] "  note: ISBN 978-1138700109"                                                 
#> [27] "  URL: https://github.com/rstudio/bookdown"                                  
#> [28] "..."
rmarkdown::find_pandoc(cache = FALSE, dir = "C:/Users/chris/Logiciel/pandoc/pandoc-2.11/")
#> $version
#> [1] '2.11'
#> 
#> $dir
#> [1] "C:/Users/chris/Logiciel/pandoc/pandoc-2.11/"
rmarkdown::pandoc_citeproc_convert(temp_bib, type = "yaml")
#>  [1] "---"                                                                
#>  [2] "references:"                                                        
#>  [3] "- author:"                                                          
#>  [4] "  - family: Xie"                                                    
#>  [5] "    given: Yihui"                                                   
#>  [6] "  id: R-bookdown"                                                   
#>  [7] "  issued: 2020"                                                     
#>  [8] "  note: R package version 0.20.6"                                   
#>  [9] "  title: \"Bookdown: Authoring books and technical documents with r"
#> [10] "    markdown\""                                                     
#> [11] "  title-short: Bookdown"                                            
#> [12] "  type: book"                                                       
#> [13] "  url: \"https://github.com/rstudio/bookdown\""                     
#> [14] "- author:"                                                          
#> [15] "  - family: Xie"                                                    
#> [16] "    given: Yihui"                                                   
#> [17] "  id: bookdown2016"                                                 
#> [18] "  issued: 2016"                                                     
#> [19] "  note: ISBN 978-1138700109"                                        
#> [20] "  publisher: Chapman; Hall/CRC"                                     
#> [21] "  publisher-place: Boca Raton, Florida"                             
#> [22] "  title: \"Bookdown: Authoring books and technical documents with R"
#> [23] "    markdown\""                                                     
#> [24] "  title-short: Bookdown"                                            
#> [25] "  type: book"                                                       
#> [26] "  url: \"https://github.com/rstudio/bookdown\""                     
#> [27] "---"                                                                
#> [28] ""

Created on 2020-10-12 by the reprex package (v0.3.0.9001)

Do we need to get the output of pandoc_citeproc_convert to be the same no matter which pandoc version used ?
I believe we should just provide a wrapper to make the conversion but keep the output as the pandoc binary or pandoc-citeproc binary is doing. That would mean not remove the nocite maybe.

What do you think ?

@jjallaire
Copy link
Member

I agree it's fine to keep the nocite in there until we discover there is a reason to remove it.

@CLAassistant
Copy link

CLAassistant commented Oct 12, 2020

CLA assistant check
All committers have signed the CLA.

@jjallaire
Copy link
Member

@cderv FYI I wanted to bump the version in DESCRIPTION so I merged master into new-citeproc.

@cderv cderv marked this pull request as ready for review October 12, 2020 16:18
@cderv
Copy link
Collaborator Author

cderv commented Oct 12, 2020

That is good idea ! I forgot to bump it thanks!

This should be ready. Pandoc 2.11+ is now tested and will not use pandoc-citeproc now.

@cderv cderv requested a review from yihui October 12, 2020 16:20
@cderv cderv requested a review from jjallaire October 12, 2020 16:20
@jjallaire
Copy link
Member

@yihui Are you okay if we go ahead and merge this?

@yihui
Copy link
Member

yihui commented Oct 12, 2020

@jjallaire Hold on please. There seems to be something wrong with the merge commit c14b967 that you pushed. We lost some commits there. It might be because I deleted 3077b34 and 348ed78 from the master branch (since the latter just reverted the former). Sorry about that, but I guess we have to get rid of c14b967. Are you okay with me doing that? It'll be a force push...

@jjallaire
Copy link
Member

jjallaire commented Oct 12, 2020 via email

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. The PR looks good to me, and I'll merge it right now. Thanks!

@yihui yihui merged commit 8606e3c into master Oct 12, 2020
@yihui yihui deleted the new-citeproc branch October 12, 2020 21:41
@yihui
Copy link
Member

yihui commented Oct 12, 2020

@jjallaire I've restored the master branch, and you may have to clone the repo again.

@jjallaire
Copy link
Member

jjallaire commented Oct 12, 2020 via email

@doronbehar

This comment has been minimized.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support new pandoc 2.11 --citeproc option to deal with citations
5 participants