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

Correctly move references in margin with Pandoc 2.11 new citeproc #86

Merged
merged 4 commits into from
Oct 15, 2020

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Oct 14, 2020

This will close #85

First change is to take into account the new classes added by Pandoc. Ex:

<div id="ref-xie2015" class="csl-entry">
Xie, Yihui. 2015. <em>Dynamic Documents with <span>R</span> and Knitr</em>. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. <a href="http://yihui.name/knitr/">http://yihui.name/knitr/</a>.
</div>

Second change is that new citeproc will generate two links, e.g Allaire et al. (2020)

<span class="citation"><a href="#ref-R-rmarkdown" role="doc-biblioref">Allaire et al.</a> (<a href="#ref-R-rmarkdown" role="doc-biblioref">2020</a>)</span>

Previously with Pandoc 2.7, we had only one, e.g Allaire et al. (2020)

<span class="citation">Allaire et al. (<a href="#ref-R-rmarkdown" role="doc-biblioref">2020</a>)</span>

And tufte seems to support from a long time now, merging links (d6a5748) - it seems to be for 2016a, so year with suffix.

@yihui, I tried to follow the same logic with regex (and it is a use case for regexec maybe?).
However, I wonder if we should not have a condition on rmarkdown::pandoc_available("2.11") to have a new regex for new citeproc. Two processing for this, depending on the Pandoc version.
In fact, I am not sure if there won't be more than 2 links sometimes. How do I generate a reference entry with a alphatetic suffix to try with Pandoc 2.11 ?

Also, with this PR, the linked will be merged and, with Pandoc 2.11+, we will have the toggle logic to apply on the all Name + year (Allaire et al. (2020)) and not just the year as before.

With Pandoc 2.11:
image

With Pandoc 2.7.3:
image

I left this PR as a draft as I am not sure of the fix and this need to be tested with alphabetic suffix

…11 new output.

It happens that Pandoc 2.11 `--citeproc` is also generating two links, one for the names and one for the year, separated by parenthesis, e.g
<span class="citation"><a href="#ref-R-rmarkdown" role="doc-biblioref">Allaire et al.</a> (<a href="#ref-R-rmarkdown" role="doc-biblioref">2020</a>)</span>

Let's not that previous version Pandoc 2.7.3 is only generating a link for the year.
@cderv cderv requested a review from yihui October 14, 2020 15:48
@cderv
Copy link
Collaborator Author

cderv commented Oct 14, 2020

How do I generate a reference entry with a alphatetic suffix to try with Pandoc 2.11 ?

In fact, this is when two entries have the authors and years. I tested ny adding flextable and officer in knitr::write_bib(c('base', 'rmarkdown', 'flextable', 'officer'), file = 'skeleton.bib')

then referencing them in the text. It works ok
image

This is because new citeproc will not generate two links, it will be (Gohel 2020a) before tufte processing

Note that with Pandoc 2.11, [@R-flextable] will generate one link between parenthesis, and @R-flextable will generate two links, one for the author, and one for the year, parenthesis around the year not being included.

@cderv
Copy link
Collaborator Author

cderv commented Oct 14, 2020

And on the contrary of what I did for bookdown, the classes added by Pandoc to style the references div is not kept here. Are you fine with that ?

I think it is ok because tufte is a very special styled format.

@cderv
Copy link
Collaborator Author

cderv commented Oct 14, 2020

I tested that this both works for Pandoc 2.7.3 where
Gohel (2020a) needs to be merge in one 2020a and with Pandoc 2.11 where Allaire et al. (2020) needs to be merge also in one Allaire et al. (2020)

@cderv cderv marked this pull request as ready for review October 14, 2020 16:10
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.

Looks good to me. Thank you!

@yihui yihui merged commit 52aaff5 into master Oct 15, 2020
@yihui yihui deleted the fix-85 branch October 15, 2020 18:00
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 4, 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.

Check citation processing with new citeproc from Pandoc 2.11
2 participants