Closed AdrianHordyk closed 2 years ago
This could potentially be fixed, but detecting the context like that might be tricky. Have you considered using getSlot()
instead of @
?
Yea, can use slot
instead of @
. Though it's not uncommon to access S4 objects in a list with list[[i]]@slot
, and it wasn't obvious where the error was coming from until I did a line-by-line. So likely to be a problem for others again in this context.
Would it ever need to search for citations in a code block?
The problem is I'm not sure how easy or reliable it would be to detect if the citation is in a code block or not because that isn't really connected to the @
at all. @paleolimbot would be able to say more.
I know that using @
as an accessor is common, but I'd argue it's also a little against the S4 ethos to dig into the innards of an object manually rather than use methods.
The flip side of this is that you might want citations that are included in a figure or table caption, both of which might be in a code block. This isn't the first time it's come up though and often S4 objects are poorly designed and using them reliably requires hacking with the @
.
I'd be happy to merge this but I think a few changes are needed:
include_code_chunks
) that can be set to TRUE
to skip this step.stringr::str_remove_all()
(slightly more compact)I'm also pretty sure that you can have a backtick in a code chunk. Would .*?
work instead of [^`]
?
This is awesome! I had this open on my computer so I pushed a version of this to master. Thank you!
I was having an issue where S4 slots in code blocks were being detected as citations.
Eg,
rbbt::bbt_write_bib
was resulting in errorSlot
not found with:My fix was to drop all code blocks from the content object. It works for me, but not sure if it is robust for all situations.