File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -53,11 +53,27 @@ spod_cite <- function(
5353 format <- setdiff(format , " all" )
5454
5555 # 4. Get the citation object
56- cit <- utils :: citation(" spanishoddata" )
56+ cit <- tryCatch(
57+ {
58+ suppressWarnings(utils :: citation(" spanishoddata" ))
59+ },
60+ error = function (e ) {
61+ # Fallback for devtools::load_all() or test environments
62+ citation_file <- system.file(" CITATION" , package = " spanishoddata" )
63+ if (citation_file == " " ) {
64+ stop(" CITATION file not found." )
65+ }
66+ readCitationFile(citation_file , meta = list (Encoding = " UTF-8" ))
67+ }
68+ )
5769
5870 # 5. Function to get citation by key
5971 get_citation_by_key <- function (key ) {
60- idx <- which(purrr :: map_lgl(cit , ~ .x $ key == key ))
72+ idx <- which(purrr :: map_lgl(cit , function (x ) {
73+ # Try multiple ways to access the key
74+ entry_key <- x $ key %|| % attr(x , " key" ) %|| % x [[" key" ]]
75+ isTRUE(entry_key == key )
76+ }))
6177 if (length(idx ) > 0 ) {
6278 return (cit [idx ])
6379 }
You can’t perform that action at this time.
0 commit comments