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
Handle duplicate numeric footnotes via pandoc --file-scope #897
Conversation
…meter. Numeric footnotes duplicated across chapters are now automatically renumbered. This is done by passing the `--file-scope` argument to pandoc (and having it operate on split out individual chapters of the target .md file rather than a combined file). This behavior can be toggled off by setting `pandoc_file_scope` to `false` in `_bookdown.yml`. See also rstudio/rmarkdown#1837 (which this PR depends on)
A consequence of using As a result I think that this behavior should be disabled by default. I'll make that change to the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good. One question: with --file-scope
, do internal links still work? https://pandoc.org/MANUAL.html#internal-links
The first form works -- To me this implies that I should not make this the default in the project template, as I think users should explicitly opt in to this behavior and understand the pros/cons rather than have it set by default. I'll update the PR. |
Some more thoughts on how we could make this work better.
My biggest reservation about (4) is that there are some scenarios where it doesn't work at all (and thus all footnotes are off by one, etc.). I can't say what these scenarios would be, just that there is some risk that they exist. I guess this risk is mitigated a bit by the fact that we'd only do it if we saw the duplicate footnote warning in the first place. I prefer (3) or (4) as solutions as they require less user fiddling/complexity/failure modes. Let me know what you think.... |
@jcheng5 and I talked realtime about this today and agreed that the following scheme should work with very little risk of error or disruption of existing bookdown projects:
I think all of this nets out to the following:
@yihui If this sounds okay to you I'll update the PR (and possibly find a better name for the argument/option) and then put the logic described in (4) into rmarkdown. |
@jjallaire that sounds good to me too |
rmarkdown will be updated to only use `--file-scope` if it actually detects duplicate footnote identifiers
Okay, I have changed the name of the parameter to |
I've been struggling w/ the naming/semantics of the argument/option and I think I have a better approach. The crux of the problem is that bookdown is providing something very general to I think we need to separate these concepts:
|
I just pushed a new scheme which I think is much more sensible. In summary:
In this new scheme, we simply explain to users that they can use duplicated numeric footnotes if they'd like to (note that w/ the visual editor this is currently the only option) and they'll be handled correctly subject to the constraints of |
I made the change to use just
|
…e length(x) could be 0)
…bled (e.g. for html_document2)
…d be just pos[i] instead of pos[i] - 1
…es[i], its content is always from pos[i] + 1 to pos[i + 1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This is fantastic work! Thanks everybody. I've been running a previous version of bookdown and just discovered this problem. And here you've already fixed it! 👍 |
I meant to make a new CRAN release as soon as possible but haven't gotten the time yet. I'll try next week. |
Ugh. I didn't realize this had been removed. Isn't it possible to leave this in but check for duplicate section titles and disable --file-scope if they are found? I'm really at a loss right now about how to handle footnotes. By far the most obvious way to do them is to number them per chapter, but right now in the latest dev version, that outputs a book with totally screwed up footnotes (edit: with warning). |
@jtbayly It was not removed, but disabled by default: 285cba4 You can re-enable it through the global option by yourself if you want, but I'm not sure why you would want to do that. Our original motivation to add this feature is no longer there: the R Markdown visual editor in RStudio supports footnotes well, so we don't really need this feature ourselves. Update: Oh I just saw https://community.rstudio.com/t/how-can-i-enable-the-file-scope-option/83741/7. |
Yeah, I was going to throw that link up. One other thing to consider: most of my editors won't be using RStudio. The beauty of markdown being that it can be edited in any text editor, and all that. :) |
Discussion [ici](rstudio/bookdown#897)
Numeric footnotes duplicated across chapters can now automatically renumbered. This is done by setting the
pandoc_file_scope
option totrue
in_bookdown.yml
, which results in the use of the--file-scope
(https://pandoc.org/MANUAL.html#option--file-scope) argument to pandoc (and having it operate on split out individual chapters of the target .md file rather than a combined file).See also rstudio/rmarkdown#1837 (which this PR depends on)