Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write_pgfkeys <- function(x, ...) {
- UseMethod("write_pgfkeys")
- }
- .pgfkey <- function(key, value) {
- str_c("\\pgfkeysetvalue{", key, "}{", value, "}")
- }
- write_pgfkeys.default <- function(x, path=NULL, root = "/data/", ...) {
- keys <- str_c(root, names(x)) %>%
- # ensure leading and trailing / and no //
- str_replace("^/*", "/") %>%
- str_replace("/*$", "/") %>%
- str_replace("//", "/")
- out <- str_c(map2_chr(keys, as.character(x), .pgfkey), collapse = "\n")
- if (!is.null(path)) {
- cat(out, file = path)
- }
- invisible(out)
- }
- write_pgfkeys.environment <- function(x, ....) {
- v <- set_names(map_chr(names(x), function(i) as.character(x[[i]])),
- names(x))
- write_pgfkeys.character(v)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement