Load a CSL style

csl_style_load(input, ...)

Arguments

input

URL or local file path

...

Curl options passed on to crul::HttpClient

Value

named list, including slots for

  • info: basic top level information

  • locale: locale information, if it exists

  • macros: macros, 1 to many

  • citation: the citation format, very messy now as the format is messy, parsed with xml2::as_list

  • bibliography: very messy for now, we just run xml2::as_list on this element as it's complicated to parse

Details

This function fetches the style XML document, and parses it into a more reasonble R list that's easy to navigate. If you want the raw XML, see csl_style_xml()

Examples

# Load a style from the Zotero style repository x <- 'http://www.zotero.org/styles/american-journal-of-political-science' if (crul::ok(x)) { jps <- csl_style_load(x) ## Query style information jps$info jps$locale jps$macros jps$citation jps$bibliography }
#> $attributes #> $attributes$`hanging-indent` #> [1] "true" #> #> $attributes$`et-al-min` #> [1] "4" #> #> $attributes$`et-al-use-first` #> [1] "1" #> #> $attributes$`entry-spacing` #> [1] "0" #> #> #> $sort #> $sort$key #> $sort$key[[1]] #> $sort$key[[1]]$macro #> [1] "author" #> #> #> $sort$key[[2]] #> $sort$key[[2]]$variable #> [1] "title" #> #> #> #> #> $layout #> $layout[[1]] #> $layout[[1]]$text #> list() #> attr(,"macro") #> [1] "author" #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$date #> $layout[[1]]$date$`date-part` #> list() #> attr(,"name") #> [1] "year" #> #> attr(,"variable") #> [1] "issued" #> attr(,"prefix") #> [1] " " #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$choose #> $layout[[1]]$choose$`if` #> $layout[[1]]$choose$`if`$text #> list() #> attr(,"macro") #> [1] "legal_case" #> #> $layout[[1]]$choose$`if`$group #> $layout[[1]]$choose$`if`$group$text #> list() #> attr(,"macro") #> [1] "title" #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$choose$`if`$group$text #> list() #> attr(,"macro") #> [1] "edition" #> #> $layout[[1]]$choose$`if`$group$text #> list() #> attr(,"macro") #> [1] "editor" #> attr(,"suffix") #> [1] "." #> #> attr(,"prefix") #> [1] " " #> attr(,"delimiter") #> [1] " " #> #> $layout[[1]]$choose$`if`$text #> list() #> attr(,"prefix") #> [1] " " #> attr(,"suffix") #> [1] "." #> attr(,"macro") #> [1] "publisher" #> #> attr(,"type") #> [1] "bill book graphic legal_case legislation manuscript motion_picture report song thesis" #> attr(,"match") #> [1] "any" #> #> $layout[[1]]$choose$`else-if` #> $layout[[1]]$choose$`else-if`$text #> list() #> attr(,"macro") #> [1] "title" #> attr(,"prefix") #> [1] " " #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$choose$`else-if`$group #> $layout[[1]]$choose$`else-if`$group$text #> list() #> attr(,"term") #> [1] "in" #> attr(,"text-case") #> [1] "capitalize-first" #> #> $layout[[1]]$choose$`else-if`$group$text #> list() #> attr(,"variable") #> [1] "container-title" #> attr(,"font-style") #> [1] "italic" #> attr(,"suffix") #> [1] "," #> #> $layout[[1]]$choose$`else-if`$group$text #> list() #> attr(,"variable") #> [1] "collection-title" #> attr(,"suffix") #> [1] "," #> #> $layout[[1]]$choose$`else-if`$group$text #> list() #> attr(,"macro") #> [1] "editor" #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$choose$`else-if`$group$group #> $layout[[1]]$choose$`else-if`$group$group$text #> list() #> attr(,"macro") #> [1] "publisher" #> #> $layout[[1]]$choose$`else-if`$group$group$group #> $layout[[1]]$choose$`else-if`$group$group$group$text #> list() #> attr(,"variable") #> [1] "page" #> attr(,"prefix") #> [1] "p. " #> #> attr(,"prefix") #> [1] ", " #> #> attr(,"suffix") #> [1] "." #> #> attr(,"prefix") #> [1] " " #> attr(,"delimiter") #> [1] " " #> #> attr(,"type") #> [1] "chapter paper-conference" #> attr(,"match") #> [1] "any" #> #> $layout[[1]]$choose$`else` #> $layout[[1]]$choose$`else`$group #> $layout[[1]]$choose$`else`$group$text #> list() #> attr(,"macro") #> [1] "title" #> #> $layout[[1]]$choose$`else`$group$text #> list() #> attr(,"macro") #> [1] "editor" #> #> attr(,"prefix") #> [1] " " #> attr(,"delimiter") #> [1] " " #> attr(,"suffix") #> [1] "." #> #> $layout[[1]]$choose$`else`$group #> $layout[[1]]$choose$`else`$group$text #> list() #> attr(,"variable") #> [1] "container-title" #> attr(,"font-style") #> [1] "italic" #> #> $layout[[1]]$choose$`else`$group$group #> $layout[[1]]$choose$`else`$group$group$text #> list() #> attr(,"variable") #> [1] "volume" #> #> $layout[[1]]$choose$`else`$group$group$text #> list() #> attr(,"variable") #> [1] "issue" #> attr(,"prefix") #> [1] "(" #> attr(,"suffix") #> [1] ")" #> #> attr(,"prefix") #> [1] " " #> #> $layout[[1]]$choose$`else`$group$text #> list() #> attr(,"variable") #> [1] "page" #> attr(,"prefix") #> [1] ": " #> #> attr(,"prefix") #> [1] " " #> attr(,"suffix") #> [1] "." #> #> #> #> $layout[[1]]$text #> list() #> attr(,"prefix") #> [1] " " #> attr(,"macro") #> [1] "access" #> attr(,"suffix") #> [1] "." #> #> attr(,"suffix") #> [1] "." #> #>
if (FALSE) { # fetch styles csl_fetch_styles() # Load from a local style file ## just specify the style and we read from the local style files csl_style_load(input="apa") csl_style_load("computer-und-recht") csl_style_load("bulletin-de-correspondance-hellenique") }