jumpingrivers / namer

R package :package: for labelling chunks of RMarkdown files! :boom:
https://jumpingrivers.github.io/namer/
Other
94 stars 11 forks source link

Clean latex special characters for bookdown labels #18

Closed charliejhadley closed 5 years ago

charliejhadley commented 5 years ago

Bookdown provides support for captions and other internal referencing via the use of chunk names.

As warned here https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references it's advised not to use underscores in chunk labels as they're escaped in LateX

Jenny Bryan's excellent "how to name files" slide deck https://speakerdeck.com/jennybc/how-to-name-files encourages the following:

YYYY-MM-DD_semantic-component-1_component-2

This PR introduces clean_latex_special_characters which replaces all LaTeX special characters in filenames with - and also removes duplicate dashes.

maelle commented 5 years ago

Thanks! Could you please:

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 60


Totals Coverage Status
Change from base Build 58: 0.4%
Covered Lines: 94
Relevant Lines: 97

💛 - Coveralls
maelle commented 5 years ago

Thank you!

charliejhadley commented 5 years ago

Hey @maelle I was wondering if I should reopen this and extend the namer package to check existing code chunks for LaTeX special characters?

maelle commented 5 years ago

I'm not sure I understand what the new functionality would be?

charliejhadley commented 5 years ago

@maelle sorry for being vague. My idea was to have a function name_chunks_strictly() which would replace LaTeX special characters with - to ensure compatibility with advanced Rmd features. This could then be an option in a UI for the add-in.

However, this might be considered beyond scope and dangerous as we'd be potentially removing important data from the code chunk names.

maelle commented 5 years ago

Ok, thanks for clarifying! Do you however consider your (merged) PR to be dangerous too i.e. should the filename cleaning be optional too?

charliejhadley commented 5 years ago

Hmm. I don’t think it’s dangerous because it’s inserting chunk names that are completely new, and safe. Editing names that a user has deliberately chosen is more dangerous, I think. What do you think?

On Mon, 3 Dec 2018 at 13:13, Maëlle Salmon notifications@github.com wrote:

Ok, thanks for clarifying! Do you however consider your (merged) PR to be dangerous too i.e. should the filename cleaning be optional too?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lockedata/namer/pull/18#issuecomment-443705383, or mute the thread https://github.com/notifications/unsubscribe-auth/AI7fP0O3wPJWMIFQv_Ii2bRnhAHnaI4Vks5u1SNrgaJpZM4Ys_Xe .

maelle commented 5 years ago

Ok! Feel free to open an issue about your other idea if you want!