Skip to content

Commit 288bdca

Browse files
improve text and examples
1 parent f7dcef4 commit 288bdca

File tree

2 files changed

+73
-13
lines changed

2 files changed

+73
-13
lines changed

README.Rmd

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ knitr::opts_chunk$set(
1919
![MaybeNotHelpful](https://img.shields.io/badge/NeverMind-MaybeNotHelpful-green)
2020

2121
This package focuses solely on "extra" functions related to citeing bibliography
22-
items such as processing .bib files to get citation keys, processing BiBtex keys to get inline citations, etc. This work was
23-
inspired by the need to find a way to process citation keys to inline citation text in DT tables as rendering in rmarkdown does
24-
not produce the results we desire so we need to do it with manual calls to `pandoc`.
22+
items such as processing .bib files to get citation keys, processing BiBtex keys to get inline citations, etc. We
23+
are calling it "extra" because we rely heavily on [`rbbt`](https://github.com/paleolimbot/rbbt) and standard
24+
`rmarkdown::render` magic to almost everything we need to do. Some functions for rendering citation keys
25+
as inline references wrap calls to `pandoc` so that needs to be installed. If you have Rstudion you likely have it already.
26+
27+
This package deals with a few problems as follows:
28+
29+
- Identify all citation keys in documents and confirm their presence in a specified .bib file.
30+
- Highlight citation keys that do not match and suggest the closest matching keys from the .bib file.
31+
- Provide workarounds for citation handling in interactive tables [(DT)](https://github.com/rstudio/DT) and other HTML
32+
outputs where standard citation rendering in R Markdown and Quarto may fail.
2533

2634
## Installation
2735

@@ -34,22 +42,39 @@ pak::pkg_install("NewGraphEnvironment/xciter")
3442

3543
## Example
3644

37-
This is a basic example which shows you how to solve a common problem:
45+
This is a basic example of subbing citation keys for inline references within a table so that it can
46+
be rendered as is after the changes are made:
3847

3948
```{r example}
4049
library(xciter)
4150
## basic example code
4251
43-
path_bib <- system.file("extdata", "references.bib", package = "xciter")
52+
path_bib <- system.file("extdata", "NewGraphEnvironment.bib", package = "xciter")
4453
dat <- data.frame(
4554
id = 1:3,
4655
bib_keys = c(
4756
"Outside block quotes @busch_etal2011LandscapeLevelModela and in [@woll_etal2017SalmonEcological]",
48-
"This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventory]",
57+
"This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventorya]",
4958
"this is a failed key @key3"
5059
)
5160
)
5261
result <- xct_keys_to_inline_table_col(dat, col_format = "bib_keys", path_bib = path_bib)
5362
print(result)
5463
```
5564

65+
This is a basic example of checking if the citation keys within a bookdown document are found within a specified
66+
`.bib` file.
67+
68+
```{r}
69+
key_missing <- xct_bib_keys_missing(path_bib, "kirsch_etal2014Fishinventory")
70+
```
71+
72+
73+
<br>
74+
75+
This is an example of how to search for the closest match for an unmatched key.
76+
77+
```{r}
78+
xct_keys_guess_match(key_missing, keys_bib = xct_bib_keys_extract(path_bib))
79+
```
80+

README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@
88

99
This package focuses solely on “extra” functions related to citeing
1010
bibliography items such as processing .bib files to get citation keys,
11-
processing BiBtex keys to get inline citations, etc. This work was
12-
inspired by the need to find a way to process citation keys to inline
13-
citation text in DT tables as rendering in rmarkdown does not produce
14-
the results we desire so we need to do it with manual calls to `pandoc`.
11+
processing BiBtex keys to get inline citations, etc. We are calling it
12+
“extra” because we rely heavily on
13+
[`rbbt`](https://github.com/paleolimbot/rbbt) and standard
14+
`rmarkdown::render` magic to almost everything we need to do. Some
15+
functions for rendering citation keys as inline references wrap calls to
16+
`pandoc` so that needs to be installed. If you have Rstudion you likely
17+
have it already.
18+
19+
This package deals with a few problems as follows:
20+
21+
- Identify all citation keys in documents and confirm their presence in
22+
a specified .bib file.
23+
- Highlight citation keys that do not match and suggest the closest
24+
matching keys from the .bib file.
25+
- Provide workarounds for citation handling in interactive tables
26+
[(DT)](https://github.com/rstudio/DT) and other HTML outputs where
27+
standard citation rendering in R Markdown and Quarto may fail.
1528

1629
## Installation
1730

@@ -25,18 +38,20 @@ pak::pkg_install("NewGraphEnvironment/xciter")
2538

2639
## Example
2740

28-
This is a basic example which shows you how to solve a common problem:
41+
This is a basic example of subbing citation keys for inline references
42+
within a table so that it can be rendered as is after the changes are
43+
made:
2944

3045
``` r
3146
library(xciter)
3247
## basic example code
3348

34-
path_bib <- system.file("extdata", "references.bib", package = "xciter")
49+
path_bib <- system.file("extdata", "NewGraphEnvironment.bib", package = "xciter")
3550
dat <- data.frame(
3651
id = 1:3,
3752
bib_keys = c(
3853
"Outside block quotes @busch_etal2011LandscapeLevelModela and in [@woll_etal2017SalmonEcological]",
39-
"This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventory]",
54+
"This is many [@busch_etal2011LandscapeLevelModela; @woll_etal2017SalmonEcological; @kirsch_etal2014Fishinventorya]",
4055
"this is a failed key @key3"
4156
)
4257
)
@@ -51,3 +66,23 @@ print(result)
5166
#> 2 This is many (Busch et al. 2011; Woll, Albert, and Whited 2017; Kirsch, Buckwalter, and Reed 2014)
5267
#> 3 this is a failed key (key3?)
5368
```
69+
70+
This is a basic example of checking if the citation keys within a
71+
bookdown document are found within a specified `.bib` file.
72+
73+
``` r
74+
key_missing <- xct_bib_keys_missing(path_bib, "kirsch_etal2014Fishinventory")
75+
#> ! The following citations were not found in the BibTeX file:
76+
#> [1] "kirsch_etal2014Fishinventory"
77+
```
78+
79+
<br>
80+
81+
This is an example of how to search for the closest match for an
82+
unmatched key.
83+
84+
``` r
85+
xct_keys_guess_match(key_missing, keys_bib = xct_bib_keys_extract(path_bib))
86+
#> key_missing key_missing_guess_match
87+
#> 1 kirsch_etal2014Fishinventory kirsch_etal2014Fishinventorya
88+
```

0 commit comments

Comments
 (0)