diff --git a/DESCRIPTION b/DESCRIPTION
index 37d20d8..490cd47 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,27 +1,33 @@
Package: rbbt
Title: R Interface to the Better BiBTex Zotero Connector
-Version: 0.0.0.9000
+Version: 0.0.1
+Date: 2023-08-02
Authors@R: c(person("Dewey", "Dunnington",
email = "dewey@fishandwhistle.net", role = c("aut", "cre")),
person("Brenton M.", "Wiernik",
- email = "brenton@wiernik.org", role = c("aut"))
+ email = "brenton@wiernik.org", role = c("aut")),
+ person("Wencheng", "Lau-Medrano",
+ email = "brenton@wiernik.org", role = c("ctb"))
)
Description: Connects R to the Better Bibtex for Zotero connector
.
-Depends: R (>= 3.4.0)
+Depends: R (>= 4.1.0)
License: GPL-3
Encoding: UTF-8
LazyData: true
-RoxygenNote: 7.1.1
+RoxygenNote: 7.2.3
Imports:
httr,
rstudioapi,
clipr,
knitr,
+ xfun,
readr,
stringr,
rmarkdown,
- fs
+ fs,
+ tools,
+ utils
Roxygen: list(markdown = TRUE)
URL: https://github.com/paleolimbot/rbbt
BugReports: https://github.com/paleolimbot/rbbt/issues
diff --git a/NAMESPACE b/NAMESPACE
index 02e235e..03134e7 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -22,3 +22,30 @@ export(bbt_return)
export(bbt_update_bib)
export(bbt_write_bib)
export(has_bbt)
+importFrom(clipr,clipr_available)
+importFrom(clipr,read_clip)
+importFrom(clipr,write_clip)
+importFrom(fs,is_absolute_path)
+importFrom(httr,GET)
+importFrom(httr,POST)
+importFrom(httr,build_url)
+importFrom(httr,content)
+importFrom(httr,parse_url)
+importFrom(knitr,current_input)
+importFrom(knitr,purl)
+importFrom(readr,default_locale)
+importFrom(readr,read_file)
+importFrom(readr,write_file)
+importFrom(rmarkdown,yaml_front_matter)
+importFrom(rstudioapi,getActiveDocumentContext)
+importFrom(rstudioapi,insertText)
+importFrom(rstudioapi,isAvailable)
+importFrom(stringr,regex)
+importFrom(stringr,str_extract)
+importFrom(stringr,str_match_all)
+importFrom(stringr,str_subset)
+importFrom(tools,file_ext)
+importFrom(utils,URLencode)
+importFrom(utils,citation)
+importFrom(utils,toBibtex)
+importFrom(xfun,split_lines)
diff --git a/R/addin.R b/R/addin.R
index 36a50f4..37ee4ec 100644
--- a/R/addin.R
+++ b/R/addin.R
@@ -1,7 +1,7 @@
bbt_cite_addin <- function() {
# get the likely citation type from the current document context
- context <- rstudioapi::getActiveDocumentContext()
+ context <- getActiveDocumentContext()
bbt_cite_cayw(
format = bbt_guess_format(bbt_rstudio_editor_filepath()),
.action = bbt_insert
@@ -17,7 +17,7 @@ bbt_bib_addin <- function() {
bbt_update_bib_addin <- function() {
context <- bbt_rstudio_editor_filepath()
- if (!(tools::file_ext(context) %in% c("qmd", "Qmd", "rmd", "Rmd"))) {
+ if (!(file_ext(context) %in% c("qmd", "Qmd", "rmd", "Rmd"))) {
stop("Currently selected editor is not a .qmd, .rmd or .Rmd file", call. = FALSE)
}
@@ -26,7 +26,7 @@ bbt_update_bib_addin <- function() {
}
bbt_rstudio_editor_filepath <- function() {
- context <- rstudioapi::getActiveDocumentContext()
+ context <- getActiveDocumentContext()
if (is.character(context$path)) {
context$path
} else {
diff --git a/R/api.R b/R/api.R
index 3852b44..1a839a5 100644
--- a/R/api.R
+++ b/R/api.R
@@ -38,7 +38,7 @@ assert_bbt <- function() {
#'
bbt_call <- function(.endpoint, ...) {
url <- bbt_url(.endpoint = .endpoint, ...)
- httr::content(httr::GET(url), as = "text", encoding = "UTF-8")
+ content(GET(url), as = "text", encoding = "UTF-8")
}
#' @rdname bbt_call
@@ -50,8 +50,8 @@ bbt_cayw <- function(..., .action = bbt_print) {
#' @rdname bbt_call
#' @export
bbt_call_json_rpc <- function(.method, ...) {
- httr::content(
- httr::POST(
+ content(
+ POST(
bbt_url("json-rpc"),
body = list(
jsonrpc = "2.0",
@@ -71,15 +71,15 @@ bbt_url <- function(.endpoint, ...) {
if(is.null(names(args))) {
url <- paste0(
.endpoint, "?", paste0(
- vapply(args, utils::URLencode, reserved=TRUE, FUN.VALUE = character(1)),
+ vapply(args, URLencode, reserved=TRUE, FUN.VALUE = character(1)),
collapse = "&"
)
)
} else {
stopifnot(all(names(args) != ""))
- url <- httr::parse_url(.endpoint)
+ url <- parse_url(.endpoint)
url$query <- as.list(args)
- url <- httr::build_url(url)
+ url <- build_url(url)
}
url
diff --git a/R/bbt-libraries.R b/R/bbt-libraries.R
index 420f336..8609554 100644
--- a/R/bbt-libraries.R
+++ b/R/bbt-libraries.R
@@ -14,7 +14,7 @@
#' if (has_bbt()) bbt_libraries()
#'
bbt_libraries <- function() {
- groups <- rbbt::bbt_call_json_rpc("user.groups")
+ groups <- bbt_call_json_rpc("user.groups")
data.frame(
id = vapply(groups$result, function(x) x$id, integer(1)),
name = vapply(groups$result, function(x) x$name, character(1)),
diff --git a/R/bbt.R b/R/bbt.R
index e3f86f6..5f4fc76 100644
--- a/R/bbt.R
+++ b/R/bbt.R
@@ -83,6 +83,35 @@ bbt_bib <- function(keys, translator = getOption("rbbt.default.translator", "bib
return(.action(""))
}
+ index <- grep(pattern = "^rpkg_", x = keys, ignore.case = TRUE)
+
+ if(length(index) > 0){
+ rPkgs <- keys[index]
+
+ rPkgs <- gsub(pattern = "^rpkg_", replacement = "", x = rPkgs, ignore.case = TRUE)
+ rPkgs <- rPkgs |>
+
+ lapply(citation) |>
+
+ lapply(\(x) x[[1]]) |>
+
+ lapply(toBibtex) |>
+
+ lapply(as.character)
+
+ rPkgs <- mapply(x = rPkgs, y = keys[index],
+ FUN = \(x, y) c(gsub(pattern = "\\{[[:graph:]]*,$",
+ replacement = sprintf("\\{%s,", y),
+ x = x[1]), x[-1]),
+ SIMPLIFY = FALSE) |>
+
+ sapply(paste, collapse = "\n") |>
+
+ paste(collapse = "\n\n")
+
+ keys <- keys[-index]
+ }
+
assert_bbt()
translator <- match.arg(translator, choices = c("json", "biblatex", "bibtex", "cslyaml"))
result <- bbt_call_json_rpc(
@@ -95,6 +124,12 @@ bbt_bib <- function(keys, translator = getOption("rbbt.default.translator", "bib
if (!is.null(result$error)) {
stop(result$error$message, call. = FALSE)
} else {
+
+ if(length(index) > 0){
+ result$result[[3]] <- paste0(c(result$result[[3]], rPkgs, ""),
+ collapse = "\n")
+ }
+
.action(result$result[[3]])
}
}
@@ -110,8 +145,8 @@ bbt_bib <- function(keys, translator = getOption("rbbt.default.translator", "bib
#'
bbt_insert <- function(text) {
text <- paste(text, collapse = "\n")
- if(rstudioapi::isAvailable()) {
- rstudioapi::insertText(text = text)
+ if(isAvailable()) {
+ insertText(text = text)
} else {
cat(text)
}
@@ -138,6 +173,6 @@ bbt_return <- function(text) {
bbt_copy <- function(text) {
text <- paste(text, collapse = "\n")
message("Text copied to clipboard")
- clipr::write_clip(text)
+ write_clip(text)
invisible(text)
}
diff --git a/R/detect-citations.R b/R/detect-citations.R
index 8dd9916..4e4c467 100644
--- a/R/detect-citations.R
+++ b/R/detect-citations.R
@@ -1,4 +1,3 @@
-
#' Detect pandoc-style citations
#'
#' By default, this omits any references within code chunks, inline R code,
@@ -7,8 +6,8 @@
#' [nocite front matter field](https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html#Unused_References_(nocite)).
#'
#' @param path A character vector, file or URL whose contents may contain citation keys.
-#' Multiple files can be passed in as a vector (e.g., from [list.files()]).
-#' @param locale See [readr::default_locale()]. Use if encoding might
+#' Multiple files can be passed in as a vector (e.g., from \link{list.files}).
+#' @param locale See \link[readr]{default_locale}. Use if encoding might
#' be a problem.
#'
#' @return A character vector of unique citation keys.
@@ -17,15 +16,15 @@
#' @examples
#' bbt_detect_citations("\n@citation1 and [@citation2] but not \\@citation3")
#'
-bbt_detect_citations <- function(path = bbt_guess_citation_context(), locale = readr::default_locale()) {
- text <- vapply(path, readr::read_file, locale = locale, FUN.VALUE = character(1))
+bbt_detect_citations <- function(path = bbt_guess_citation_context(), locale = default_locale()) {
+ text <- vapply(path, read_file, locale = locale, FUN.VALUE = character(1))
bbt_detect_citations_chr(text)
}
#' @rdname bbt_detect_citations
#' @export
bbt_guess_citation_context <- function() {
- knitr_doc <- knitr::current_input()
+ knitr_doc <- current_input()
if (!is.null(knitr_doc)) {
knitr_doc
} else {
@@ -49,10 +48,12 @@ bbt_detect_citations_chr <- function(text) {
text <- gsub("\\(http.+?\\)", "", text)
text <- gsub("", "", text)
- refs <- stringr::str_match_all(
- text,
- stringr::regex("[^a-zA-Z0-9\\\\]@([a-zA-Z0-9_\\.\\-:]+[a-zA-Z0-9])", multiline = TRUE, dotall = TRUE)
+ refs <- str_match_all(string = text, pattern = regex("[^a-zA-Z0-9\\\\]@([a-zA-Z0-9_\\.\\-:]+[a-zA-Z0-9])",
+ multiline = TRUE, dotall = TRUE)
)[[1]][, 2, drop = TRUE]
+ index <- !grepl(pattern = "(^fig-)|(^tbl-)", x = refs, ignore.case = TRUE)
+ refs <- refs[index]
+
unique(refs)
}
diff --git a/R/rbbt.R b/R/rbbt.R
new file mode 100644
index 0000000..281ca21
--- /dev/null
+++ b/R/rbbt.R
@@ -0,0 +1,13 @@
+# rbbt
+#' @importFrom clipr clipr_available read_clip write_clip
+#' @importFrom httr content POST parse_url build_url GET
+#' @importFrom rstudioapi getActiveDocumentContext isAvailable insertText
+#' @importFrom knitr current_input purl
+#' @importFrom xfun split_lines
+#' @importFrom readr default_locale read_file write_file
+#' @importFrom stringr str_match_all regex str_subset str_extract
+#' @importFrom rmarkdown yaml_front_matter
+#' @importFrom fs is_absolute_path
+#' @importFrom tools file_ext
+#' @importFrom utils URLencode toBibtex citation
+NULL
diff --git a/R/update.R b/R/update.R
index db0b13f..ab9de7c 100644
--- a/R/update.R
+++ b/R/update.R
@@ -6,7 +6,7 @@
#'
#' @param path_rmd The path to the RMarkdown file.
#' @param path_bib The path to the bibliography file.
-#' @param encoding Passed to [rmarkdown::yaml_front_matter()]
+#' @param encoding Passed to \link[rmarkdown]{yaml_front_matter}
#' @param quiet Use `TRUE` to suppress message on successful write.
#' @inheritParams bbt_write_bib
#'
@@ -39,7 +39,7 @@ bbt_update_bib <- function(path_rmd,
#' @rdname bbt_update_bib
#' @export
bbt_guess_bib_file <- function(path_rmd, encoding = "UTF-8") {
- front_matter <- rmarkdown::yaml_front_matter(path_rmd, encoding = encoding)
+ front_matter <- yaml_front_matter(path_rmd, encoding = encoding)
if (length(front_matter$bibliography) != 1) {
stop(
sprintf("Can't guess bibliography file from '%s' front matter", path_rmd),
@@ -48,7 +48,7 @@ bbt_guess_bib_file <- function(path_rmd, encoding = "UTF-8") {
}
bib_file <- front_matter$bibliography
- if (!fs::is_absolute_path(bib_file)) {
+ if (!is_absolute_path(bib_file)) {
file.path(dirname(path_rmd), bib_file)
} else {
bib_file
diff --git a/R/write-bib.R b/R/write-bib.R
index 867b34a..e05d26b 100644
--- a/R/write-bib.R
+++ b/R/write-bib.R
@@ -41,7 +41,7 @@ bbt_write_bib <- function(path,
force(keys)
assert_bbt()
- readr::write_file(
+ write_file(
bbt_bib(
setdiff(keys, ignore),
translator,
diff --git a/README.Rmd b/README.Rmd
index 162e02a..c79e463 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -41,24 +41,28 @@ You will also need [Zotero](https://www.zotero.org/) installed and running, and
This package is most useful for the RStudio addins that insert citations and references into the editor. The "Insert Zotero Citation" will pop up a zotero search where you can search for a reference to add to your writing (Markdown, RMarkdown, or LaTeX). The "Insert Zotero Bibliography" addin inserts the bibliographical information corresponding to the selected item in the Zotero window. Finally, "Update bibliography for current document" runs `bbt_update_bib()` to update the bibliography based on the .Rmd file currently in the editor window. You can bind either of these to keyboard shortcuts in RStudio. The addins may behave differently depending on which file you have open (e.g., if you have a .bib file open, it will use the biblatex translator)...if you need more fine-grained control, try one of the console functions (like `bbt_bib()`!).
-## knitr + rmarkdown integration
+## RStudio shortcuts
-To make this work seamlessly with [knitr](https://yihui.org/knitr/) and [rmarkdown](https://rmarkdown.rstudio.com/), use the "Update bibliography for current document" addin to write your bibliography file based on the citations in the currently selected document. You can use `bbt_update_bib("some_file.Rmd")` to detect citations and write your bibliography file from the console.
+In RStudio, it is possible to assign a keyboard shortcut for **rbbt** addins. Just go to *Tools --> Modify Keyboard Shortcuts* and a small window will open with all the available commands to assign a keyboard shortcut. Then, using the **Scope** column, find the *Addin* type and configure the shortcuts for **rbbt** commands. For example: to set a shortcut for `bbt_update_bib()`, go to the row assigned for **"Update bibliography for current document from Zotero "**, click on the **Shortcut** column and press the desired key combination. It is recommended to define shortcuts for **"Update bibliography for current document from Zotero "** and **"Insert Zotero citation "** as they will be the most used.
-## Programmatically fetch bibliography info
+It should be noted that RStudio comes configured with some keyboard shortcuts, so it should be avoided that the newly defined shortcuts overlap (if this happens, a warning icon will be displayed in the shortcut assignment window).
-Fetch bibliography text using a list of Better BibTex citation keys:
+Also, for the commands to work correctly, they must be executed having the Rmd or Qmd file in the active tab in RStudio. That is to say, both addins mentioned above will detect the citations and the bibliography file from the active tab (from the main .Rmd or .Qmd file) from where the shortcut is executed, so you must make sure to have that document active when executing the commands, otherwise you will receive the following error message: **"Currently selected editor is not a .qmd, .rmd or .Rmd file "**.
-```{r, comment=""}
-# uses the citation keys you've defined with Better BibTeX
-rbbt::bbt_bib("dunnington_etal18", translator = "biblatex", .action = bbt_print)
-```
+In RStudio, it is possible to assign a keyboard shortcut for rbbt addins. Just go to Tools --> Modify Keyboard Shortcuts and a small window will open with all the available commands to assign a keyboard shortcut. Then, using the **Scope** column, find the **Addin** type and configure the shortcuts for **rbbt** commands. For example: to set a shortcut for `bbt_update_bib()`, go to the row assigned for **"Update bibliography for current document from Zotero "**, click on the **Shortcut** column and press the desired key combination. It is recommended to define shortcuts for **"Update bibliography for current document from Zotero "** and **"Insert Zotero citation "** as they will be the most used.
-Fetch bibliography text from selected items in Zotero:
+## knitr + rmarkdown integration
-```{r, comment=""}
-# uses whatever is currently selected in the zotero window
-rbbt::bbt_bib_selected(translator = "biblatex", .action = bbt_print)
-```
+To make this work seamlessly with [knitr](https://yihui.org/knitr/) and [rmarkdown](https://rmarkdown.rstudio.com/), use the "Update bibliography for current document" addin to write your bibliography file based on the citations in the currently selected document. You can use `bbt_update_bib("some_file.Rmd")` to detect citations and write your bibliography file from the console.
+
+# Versions
+
+## 0.0.1
+* Add functionality for citing R packages. Now, if the user wants to cite a R package, could indicate it in the Rmd/Qmd file with the syntax `@rpkg_NameOfPackage` (e.g. `@rpkg_rbbt`). `bbt_detect_citations` and `bbt_update_bib` are now prepared for identify this syntax and adding to the bibliography using `citation` and `toBibtex` tools.
+* R native pipe is used in some functions so now it is necessary to run **rbbt** in **R >= 4.1.0**.
+* Subtle corrections and improvements in code and documentation.
+
+## 0.0.0.9002
-
+* Changes in `bbt_detect_citations` in order to avoid including citations that starts whether with *fig-* or *tbl-* (associtaed with Quarto syntaxis).
+* Minor improvements in definiton of external functions and dependencies.
diff --git a/README.md b/README.md
index 379552b..040a9b9 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,46 @@ The addins may behave differently depending on which file you have open
translator)…if you need more fine-grained control, try one of the
console functions (like `bbt_bib()`!).
+## RStudio shortcuts
+
+In RStudio, it is possible to assign a keyboard shortcut for **rbbt**
+addins. Just go to *Tools –\> Modify Keyboard Shortcuts* and a small
+window will open with all the available commands to assign a keyboard
+shortcut. Then, using the **Scope** column, find the *Addin* type and
+configure the shortcuts for **rbbt** commands. For example: to set a
+shortcut for `bbt_update_bib()`, go to the row assigned for **“Update
+bibliography for current document from Zotero”**, click on the
+**Shortcut** column and press the desired key combination. It is
+recommended to define shortcuts for **“Update bibliography for current
+document from Zotero”** and **“Insert Zotero citation”** as they will be
+the most used.
+
+It should be noted that RStudio comes configured with some keyboard
+shortcuts, so it should be avoided that the newly defined shortcuts
+overlap (if this happens, a warning icon will be displayed in the
+shortcut assignment window).
+
+Also, for the commands to work correctly, they must be executed having
+the Rmd or Qmd file in the active tab in RStudio. That is to say, both
+addins mentioned above will detect the citations and the bibliography
+file from the active tab (from the main .Rmd or .Qmd file) from where
+the shortcut is executed, so you must make sure to have that document
+active when executing the commands, otherwise you will receive the
+following error message: **“Currently selected editor is not a .qmd,
+.rmd or .Rmd file”**.
+
+In RStudio, it is possible to assign a keyboard shortcut for rbbt
+addins. Just go to Tools –\> Modify Keyboard Shortcuts and a small
+window will open with all the available commands to assign a keyboard
+shortcut. Then, using the **Scope** column, find the **Addin** type and
+configure the shortcuts for **rbbt** commands. For example: to set a
+shortcut for `bbt_update_bib()`, go to the row assigned for **“Update
+bibliography for current document from Zotero”**, click on the
+**Shortcut** column and press the desired key combination. It is
+recommended to define shortcuts for **“Update bibliography for current
+document from Zotero”** and **“Insert Zotero citation”** as they will be
+the most used.
+
## knitr + rmarkdown integration
To make this work seamlessly with [knitr](https://yihui.org/knitr/) and
@@ -57,44 +97,24 @@ based on the citations in the currently selected document. You can use
`bbt_update_bib("some_file.Rmd")` to detect citations and write your
bibliography file from the console.
-## Programmatically fetch bibliography info
-
-Fetch bibliography text using a list of Better BibTex citation keys:
+# Versions
-``` r
-# uses the citation keys you've defined with Better BibTeX
-rbbt::bbt_bib("dunnington_etal18", translator = "biblatex", .action = bbt_print)
-
-@article{dunnington_etal18,
- title = {Anthropogenic Activity in the {{Halifax}} Region, {{Nova Scotia}}, {{Canada}}, as Recorded by Bulk Geochemistry of Lake Sediments},
- author = {Dunnington, Dewey W. and Spooner, I. S. and Krkošek, Wendy H. and Gagnon, Graham A. and Cornett, R. Jack and White, Chris E. and Misiuk, Benjamin and Tymstra, Drake},
- date = {2018-06-18},
- journaltitle = {Lake and Reservoir Management},
- volume = {34},
- number = {4},
- pages = {334--348},
- doi = {10.1080/10402381.2018.1461715},
- abstract = {Separating the timing and effects of multiple watershed disturbances is critical to a comprehensive understanding of lakes, which is required to effectively manage lacustrine systems that may be experiencing adverse water quality changes. Advances in X-ray fluorescence (XRF) technology has led to the availability of high-resolution, high-quality bulk geochemical data for aquatic sediments, which in combination with carbon, nitrogen, δ13C, and δ15N have the potential to identify watershed-scale disturbance in lake sediment cores. We integrated documented anthropogenic disturbances and changes in bulk geochemical parameters at 8 lakes within the Halifax Regional Municipality (HRM), Nova Scotia, Canada, 6 of which serve as drinking water sources. These data reflect more than 2 centuries of anthropogenic disturbance in the HRM that included deforestation, urbanization and related development, and water-level change. Deforestation activity was documented at Lake Major and Pockwock Lake by large increases in Ti, Zr, K, and Rb (50–300\%), and moderate increases in C/N ({$>$}10\%). Urbanization was resolved at Lake Fletcher, Lake Lemont, and First Lake by increases in Ti, Zr, K, and Rb (10–300\%), decreases in C/N ({$>$}10\%), and increases in δ15N ({$>$}2.0‰). These data broadly agree with previous paleolimnological bioproxy data, in some cases identifying disturbances that were not previously identified. Collectively these data suggest that bulk geochemical parameters and lake sediment archives are a useful method for lake managers to identify causal mechanisms for possible water quality changes resulting from watershed-scale disturbance.}
-}
-```
+## 0.0.1
-Fetch bibliography text from selected items in Zotero:
+- Add functionality for citing R packages. Now, if the user wants to
+ cite a R package, could indicate it in the Rmd/Qmd file with the
+ syntax `@rpkg_NameOfPackage` (e.g. `@rpkg_rbbt`).
+ `bbt_detect_citations` and `bbt_update_bib` are now prepared for
+ identify this syntax and adding to the bibliography using `citation`
+ and `toBibtex` tools.
+- R native pipe is used in some functions so now it is necessary to run
+ **rbbt** in **R \>= 4.1.0**.
+- Subtle corrections and improvements in code and documentation.
-``` r
-# uses whatever is currently selected in the zotero window
-rbbt::bbt_bib_selected(translator = "biblatex", .action = bbt_print)
-
-@article{dunnington_spooner18,
- title = {Using a Linked Table-Based Structure to Encode Self-Describing Multiparameter Spatiotemporal Data},
- author = {Dunnington, Dewey W. and Spooner, Ian S.},
- date = {2018-03-18},
- journaltitle = {FACETS},
- volume = {3},
- number = {1},
- pages = {326--337},
- doi = {10.1139/facets-2017-0026},
- abstract = {Multiparameter data with both spatial and temporal components are critical to advancing the state of environmental science. These data and data collected in the future are most useful when compared with each other and analyzed together, which is often inhibited by inconsistent data formats and a lack of structured documentation provided by researchers and (or) data repositories. In this paper we describe a linked table-based structure that encodes multiparameter spatiotemporal data and their documentation that is both flexible (able to store a wide variety of data sets) and usable (can easily be viewed, edited, and converted to plottable formats). The format is a collection of five tables (Data, Locations, Params, Data Sets, and Columns), on which restrictions are placed to ensure data are represented consistently from multiple sources. These tables can be stored in a variety of ways including spreadsheet files, comma-separated value (CSV) files, JavaScript object notation (JSON) files, databases, or objects in a software environment such as R or Python. A toolkit for users of R statistical software was also developed to facilitate converting data to and from the data format. We have used this format to combine data from multiple sources with minimal metadata loss and to effectively archive and communicate the results of spatiotemporal studies. We believe that this format and associated discussion of data and data storage will facilitate increased synergies between past, present, and future data sets in the environmental science community.}
-}
-```
+## 0.0.0.9002
-
+- Changes in `bbt_detect_citations` in order to avoid including
+ citations that starts whether with *fig-* or *tbl-* (associtaed with
+ Quarto syntaxis).
+- Minor improvements in definiton of external functions and
+ dependencies.
diff --git a/tests/testthat.R b/inst/tests/testthat.R
similarity index 100%
rename from tests/testthat.R
rename to inst/tests/testthat.R
diff --git a/tests/testthat/test-bbt-libraries.R b/inst/tests/testthat/test-bbt-libraries.R
similarity index 100%
rename from tests/testthat/test-bbt-libraries.R
rename to inst/tests/testthat/test-bbt-libraries.R
diff --git a/tests/testthat/test-bbt.R b/inst/tests/testthat/test-bbt.R
similarity index 97%
rename from tests/testthat/test-bbt.R
rename to inst/tests/testthat/test-bbt.R
index f931153..de44dcc 100644
--- a/tests/testthat/test-bbt.R
+++ b/inst/tests/testthat/test-bbt.R
@@ -29,7 +29,7 @@ test_that("actions work", {
expect_identical(bbt_return("stuff"), "stuff")
expect_output(bbt_print("stuff"), "stuff")
- if (clipr::clipr_available()) {
+ if(clipr::clipr_available()) {
prev_clip <- clipr::read_clip()
expect_message(bbt_copy("stuff"), "copied")
expect_identical(clipr::read_clip(), "stuff")
diff --git a/tests/testthat/test-detect-citations.R b/inst/tests/testthat/test-detect-citations.R
similarity index 77%
rename from tests/testthat/test-detect-citations.R
rename to inst/tests/testthat/test-detect-citations.R
index 1ab03a4..a5c2de7 100644
--- a/tests/testthat/test-detect-citations.R
+++ b/inst/tests/testthat/test-detect-citations.R
@@ -30,12 +30,21 @@ test_that("detect_citations can handle a vector of files", {
unlink(c(f1, f2))
})
-test_that("detect_citations ignores code chunks", {
- mock_content <- '
+test_that("detect_citations even insidequartocitation code chunks", {
+ mock_content <- "
```{r}
-@not_a_citation
+@not_a_citation1
+```
+
+```{r, fig.cap = 'This an example of a caption in R markdown with a @Rmcitation.'}
+@not_a_citation2
+```
+
+```{r}
+#| fig-cap: 'This an example of a caption in Quarto with a @quartocitation.'
+@not_a_citation3
```
`r @also_not_a_citation`
@@ -48,9 +57,8 @@ test_that("detect_citations ignores code chunks", {
@actual_citation
-'
-
- expect_identical(bbt_detect_citations_chr(mock_content), "actual_citation")
-
+"
+ expect_identical(bbt_detect_citations_chr(mock_content),
+ c("Rmcitation", "quartocitation", "actual_citation"))
})
diff --git a/tests/testthat/test-update.R b/inst/tests/testthat/test-update.R
similarity index 100%
rename from tests/testthat/test-update.R
rename to inst/tests/testthat/test-update.R
diff --git a/tests/testthat/test-write-bib.R b/inst/tests/testthat/test-write-bib.R
similarity index 91%
rename from tests/testthat/test-write-bib.R
rename to inst/tests/testthat/test-write-bib.R
index b116c43..edcdaee 100644
--- a/tests/testthat/test-write-bib.R
+++ b/inst/tests/testthat/test-write-bib.R
@@ -4,7 +4,7 @@ test_that("bib writer works", {
file <- tempfile(fileext = ".bib")
expect_identical(
- bbt_write_bib(file, "dunnington_etal18"),
+ bbt_write_bib(path = file, keys = "dunnington_etal18"),
file
)
expect_error(
diff --git a/man/bbt_bib_selected.Rd b/man/bbt_bib_selected.Rd
index 5ee0a82..66be0ee 100644
--- a/man/bbt_bib_selected.Rd
+++ b/man/bbt_bib_selected.Rd
@@ -18,7 +18,7 @@ bbt_bib(
)
}
\arguments{
-\item{translator}{Type of bibliography file to create. Options are \code{csljson}
+\item{translator}{Type of bibliography file to create. Options are \code{json}
(CSL-JSON), \code{biblatex} (BibLaTeX), \code{bibtex} (BibTeX), and \code{cslyaml}
(CSL YAML). CSL-JSON is recommended if users are not specifically using
a LaTeX citation processor.}
@@ -55,6 +55,6 @@ Only use BibLaTeX or BibTeX if you are using
\href{https://pandoc.org/MANUAL.html#citation-rendering}{pandoc arguments to specify an alternative citation engine for raw TeX output}.
The default translator can be changed. For example:
-\code{options(rbbt.default.translator = "csljson")}
+\code{options(rbbt.default.translator = "json")}
}
diff --git a/man/bbt_cite_cayw.Rd b/man/bbt_cite_cayw.Rd
index 9c02e8c..50cb8ea 100644
--- a/man/bbt_cite_cayw.Rd
+++ b/man/bbt_cite_cayw.Rd
@@ -17,7 +17,7 @@ bbt_bib_cayw(
\item{.action}{Use \code{\link[=bbt_return]{bbt_return()}} to return the value without printing.}
-\item{translator}{Type of bibliography file to create. Options are \code{csljson}
+\item{translator}{Type of bibliography file to create. Options are \code{json}
(CSL-JSON), \code{biblatex} (BibLaTeX), \code{bibtex} (BibTeX), and \code{cslyaml}
(CSL YAML). CSL-JSON is recommended if users are not specifically using
a LaTeX citation processor.}
@@ -47,6 +47,6 @@ Only use BibLaTeX or BibTeX if you are using
\href{https://pandoc.org/MANUAL.html#citation-rendering}{pandoc arguments to specify an alternative citation engine for raw TeX output}.
The default translator can be changed. For example:
-\code{options(rbbt.default.translator = "csljson")}
+\code{options(rbbt.default.translator = "json")}
}
diff --git a/man/bbt_detect_citations.Rd b/man/bbt_detect_citations.Rd
index 815ccfa..661f643 100644
--- a/man/bbt_detect_citations.Rd
+++ b/man/bbt_detect_citations.Rd
@@ -7,16 +7,16 @@
\usage{
bbt_detect_citations(
path = bbt_guess_citation_context(),
- locale = readr::default_locale()
+ locale = default_locale()
)
bbt_guess_citation_context()
}
\arguments{
\item{path}{A character vector, file or URL whose contents may contain citation keys.
-Multiple files can be passed in as a vector (e.g., from \code{\link[=list.files]{list.files()}}).}
+Multiple files can be passed in as a vector (e.g., from \link{list.files}).}
-\item{locale}{See \code{\link[readr:locale]{readr::default_locale()}}. Use if encoding might
+\item{locale}{See \link[readr]{default_locale}. Use if encoding might
be a problem.}
}
\value{
diff --git a/man/bbt_update_bib.Rd b/man/bbt_update_bib.Rd
index d024181..788fc89 100644
--- a/man/bbt_update_bib.Rd
+++ b/man/bbt_update_bib.Rd
@@ -26,7 +26,7 @@ bbt_guess_bib_file(path_rmd, encoding = "UTF-8")
\item{ignore}{A character vector of keys to disregard (useful if
\code{\link[=bbt_detect_citations]{bbt_detect_citations()}} gives spurious output).}
-\item{translator}{Type of bibliography file to create. Options are \code{csljson}
+\item{translator}{Type of bibliography file to create. Options are \code{json}
(CSL-JSON), \code{biblatex} (BibLaTeX), \code{bibtex} (BibTeX), and \code{cslyaml}
(CSL YAML). CSL-JSON is recommended if users are not specifically using
a LaTeX citation processor.}
@@ -44,7 +44,7 @@ of \code{\link[=bbt_bib]{bbt_bib()}} before it is written to \code{path}.}
\item{quiet}{Use \code{TRUE} to suppress message on successful write.}
-\item{encoding}{Passed to \code{\link[rmarkdown:yaml_front_matter]{rmarkdown::yaml_front_matter()}}}
+\item{encoding}{Passed to \link[rmarkdown]{yaml_front_matter}}
}
\value{
\code{path_bib}, invisibly
diff --git a/man/bbt_write_bib.Rd b/man/bbt_write_bib.Rd
index 9890999..b771a4d 100644
--- a/man/bbt_write_bib.Rd
+++ b/man/bbt_write_bib.Rd
@@ -22,7 +22,7 @@ bbt_write_bib(
\item{ignore}{A character vector of keys to disregard (useful if
\code{\link[=bbt_detect_citations]{bbt_detect_citations()}} gives spurious output).}
-\item{translator}{Type of bibliography file to create. Options are \code{csljson}
+\item{translator}{Type of bibliography file to create. Options are \code{json}
(CSL-JSON), \code{biblatex} (BibLaTeX), \code{bibtex} (BibTeX), and \code{cslyaml}
(CSL YAML). CSL-JSON is recommended if users are not specifically using
a LaTeX citation processor.}
@@ -64,7 +64,7 @@ Only use BibLaTeX or BibTeX if you are using
\href{https://pandoc.org/MANUAL.html#citation-rendering}{pandoc arguments to specify an alternative citation engine for raw TeX output}.
The default translator can be changed. For example:
-\code{options(rbbt.default.translator = "csljson")}
+\code{options(rbbt.default.translator = "json")}
}
\examples{
diff --git a/rbbt.Rproj b/rbbt.Rproj
index cba1b6b..4b56c89 100644
--- a/rbbt.Rproj
+++ b/rbbt.Rproj
@@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
-PackageRoxygenize: rd,collate,namespace
+PackageRoxygenize: rd,collate,namespace,vignette