library("knitr") hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set(output = function(x, options) { lines <- options$output.lines if (is.null(lines)) { return(hook_output(x, options)) # pass to default hook } x <- unlist(strsplit(x, "\n")) more <- "..." if (length(lines)==1) { # first n lines if (length(x) > lines) { # truncate the output, but add .... x <- c(head(x, lines), more) } } else { x <- c(if (abs(lines[1])>1) more else NULL, x[lines], if (length(x)>lines[abs(length(lines))]) more else NULL ) } # paste these lines together x <- paste(c(x, ""), collapse = "\n") hook_output(x, options) }) knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
seasl
is an R client for exploring CSL styles.
This package is inspired by the Ruby gem csl
: https://github.com/inukshuk/csl-ruby
The Citation Style Language 1.0.1 specification: http://docs.citationstyles.org/en/1.0.1/specification.html
Package API:
# cat(paste(" -", paste(sort(getNamespaceExports("seasl")), collapse = "\n - "))) cat(paste(" -", paste(sprintf("`%s`", getNamespaceExports("seasl")), collapse = "\n - ")))
install.packages("seasl")
or
remotes::install_github("ropensci/seasl")
library("seasl")
First, you may want to download style and locale files. csl_fetch_styles()
and csl_fetch_locales()
download the files to your machine. See ?csl_cache
for caching information, including
how to change the cache location.
Styles retrieved from the Github repo at https://github.com/citation-style-language/styles-distribution
csl_fetch_styles() #> #> Done! Files put in /Users/sckott/Library/Caches/R/seasl/styles
Locales retrieved from the Github repo at https://github.com/citation-style-language/locales
csl_fetch_locales() #> #> Done! Files put in /Users/sckott/Library/Caches/R/seasl/locales
calling csl_styles
without inputs gives all styles, with separate lists for
dependent and independent styles
csl_styles()
calling csl_styles
with an input gives the path to that style, if found
csl_styles("apa") csl_styles("archeologie-medievale")
Same patterns go for locales (note that there are far fewer locales than styles)
# just locale names csl_locales()
# when locale given, you get the full path csl_locales("fr-FR")
Alternatively, you can try to find a style by using csl_style_find()
# single match csl_style_find(x = "American Journal of Epidemiology")
# many matches csl_style_find(x = "American Journal")
jps <- csl_style_load('http://www.zotero.org/styles/american-journal-of-political-science')
jps$info
jps$info$title
jps$macros
jps$citation
jps$bibliography
csl_style_xml('http://www.zotero.org/styles/american-journal-of-political-science')
citation(package = 'seasl')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.