| has_heading <- !is.null(heading) | has_heading <- !is.null(heading) | ||||
| x <- paste0( | x <- paste0( | ||||
| if (has_heading) paste0("/* ", heading, " */\n"), | if (has_heading) paste0("/* ", heading, " */\n"), | ||||
| list2css(css) | |||||
| paste(list2css(css), collapse = "\n") | |||||
| ) | ) | ||||
| if (append) x <- paste0(if (has_heading) "\n\n" else "\n", x) | if (append) x <- paste0(if (has_heading) "\n\n" else "\n", x) | ||||
| if (is.null(outfile)) return(x) | if (is.null(outfile)) return(x) |
| strsplit(third_exp, "\n")[[1]] | strsplit(third_exp, "\n")[[1]] | ||||
| ) | ) | ||||
| }) | }) | ||||
| it("only adds prepends `heading` once", { | |||||
| css <- list(b = list(color = "red"), i = list(color = "blue")) | |||||
| out <- style_extra_css(css, outfile = NULL, heading = "Extra CSS") | |||||
| expect_equal(length(out), 1L) | |||||
| expect_equal(sum(grepl("Extra CSS", out)), 1L) | |||||
| }) | |||||
| }) | }) | ||||