You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Visual Editor renaming footnote references breaks order when using multiple children Rmd #10078
RStudio Edition : Server
RStudio Version : 2021.09.0+351 (Ghost Orchid) for Ubuntu Bionic
OS Version : WSL2 running under Windows 10 21H1
R Version : 4.1.2
# File 2
Text 2[^second]
[^second]: Second footnote
(2) Edit both 01.Rmd and 02.Rmd in Visual Editor, and then go back to source editor. You'll find both footnotes are renamed to [^1] in both files (since it's the first --and only-- footnote in each file). So when knit compiles index.Rmd and processes both children, you get the duplicate footnote warning (and only the second footnote in the PDF output), as they're both named the same.
Describe the problem in detail
When editing an Rmd file in visual mode, footnotes are renamed consecutively to [^1], [^2], [^n]. That happens for every file, without regard for others. So, when each file is a child of an index.Rmd, the latter footnotes override the former.
Describe the behavior you expected
Each footnote in each file should have a unique name, so as not to overlap with other children. An easy solution would be to use the filename as a prefix for the footnotenumber, so that footnotes in 01.Rmd are ordered as [^01-1]... [^01-n], while those in 02.Rmd should be `[^02-1]... [^02-n].
Edit: As far as I can tell, this kind of reference labelling already works within bookdown...
Hi J.J., thanks for looking into this. I will check the workaround. As a suggestion, maybe the visual editor could add the prefix as a default when parsing/converting/renaming footnotes? I think bookdown, which uses multiple child documents as default, has this functionality implemented.
With RStudio 2022.06.0-daily+385 "Spotted Wakerobin".
A roundtrip to source/visual/source changes the files to:
I believe this is because of this function:
exportfunctionpandocAutoIdentifier(text: string,asciify: boolean){if(asciify){text=pandocAsciify(text);}return(text// Remove all non-alphanumeric characters, except underscores, hyphens, and periods..replace(/[!"#$%&')*+,\/:;<=>?@\[\\\]^`{|}~]/g,'')// filterPunct// Replace all spaces with hyphens.replace(/\s/g,'-')// Convert all alphabetic characters to lowercase.toLowerCase()// Remove everything up to the first letter.replace(/^[^A-Za-z]+/,''));}
because of the last .replace() this returns "" for both files.
The auto behavior works otherwise, if e.g. the files are renamed "child_01.Rmd" and "child_02.Rmd". They roundtrip to:
# File 1
Text 1[^child_01-1]
[^child_01-1]: First footnote
and
# File 2
Text 2[^child_02-1]
[^child_02-1]: Second footnote
Probably you already discussed before, but I'm not finding where or when the necessity of numbering the footnotes comes. I don't think it is a good behaviour of a code editor to change markups created by the user. In this case, the footnote label could be descriptive, not a number, that is associated with a paragraph, annotation, phrase, that can be moved to another position in a file or even another file or section.
I think this change from label to number must be, if necessary, in the render process of the file, never in the editing.
I forbid myself the use of visual quarto with this behaviour.
Ah! The git diff hell for these not user commanded changes is not minor.
Reacted by Eyayaw Beze and U de Recife (in Hà Nội)
Activity
ronblum commentedon Nov 15, 2021
@Dijkie85 Thank you for opening this up as a separate issue!
jjallaire commentedon Dec 4, 2021
@Dijkie85 The best workaround for this right now is to add a reference
prefixfor child documents (as described here: https://rstudio.github.io/visual-markdown-editing/markdown.html#references). Note that if a child is included in more than one parent you will still get duplicate footnotes. I'm not sure there is a clean workaround for this in the visual editor unless/until Pandoc allows us to serialize footnotes differently (e.g. as inline so there are no id conflicts to worry about)Dijkie85 commentedon Dec 4, 2021
Hi J.J., thanks for looking into this. I will check the workaround. As a suggestion, maybe the visual editor could add the prefix as a default when parsing/converting/renaming footnotes? I think bookdown, which uses multiple child documents as default, has this functionality implemented.
jjallaire commentedon May 6, 2022
I've modified the visual editor here (b5b242b) to do the following:
Manual overrides still exist as before, including a new value
prefix: nonewhich suppresses the automatic behavior.romainfrancois commentedon May 11, 2022
btw @Dijkie85 you can use 4 backticks here if you want to show 3, I've edited the description.
romainfrancois commentedon May 11, 2022
With RStudio 2022.06.0-daily+385 "Spotted Wakerobin".
A roundtrip to source/visual/source changes the files to:
I believe this is because of this function:
because of the last
.replace()this returns "" for both files.The
autobehavior works otherwise, if e.g. the files are renamed "child_01.Rmd" and "child_02.Rmd". They roundtrip to:and
and the footnotes are correct in the rendered:
ronblum commentedon Jun 6, 2022
Verified in RStudio Desktop 2022.06.0-daily+482 on MacOS 12.5. Also switched the files to Quarto documents and verified that way, as well.
victe commentedon Nov 13, 2022
Probably you already discussed before, but I'm not finding where or when the necessity of numbering the footnotes comes. I don't think it is a good behaviour of a code editor to change markups created by the user. In this case, the footnote label could be descriptive, not a number, that is associated with a paragraph, annotation, phrase, that can be moved to another position in a file or even another file or section.
I think this change from label to number must be, if necessary, in the render process of the file, never in the editing.
I forbid myself the use of visual quarto with this behaviour.
Ah! The git diff hell for these not user commanded changes is not minor.