1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> NAME <- "html"
> source(file.path('_helper', 'init.R'))
>
> # Verify that internal css works
>
> # - HTML Output Modes ----------------------------------------------------------
>
> all.equal(
+ as.character(
+ diffPrint(
+ letters[1:3], LETTERS[1:3],
+ style=StyleHtmlLightYb(html.output="diff.only")
+ ) ),
+ rdsf(100)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(
+ letters[1:6], LETTERS[1:6],
+ style=StyleHtmlLightYb(html.output="diff.w.style")
+ ) ),
+ rdsf(200)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(
+ letters[1:6], LETTERS[1:6],
+ style=StyleHtmlLightYb(html.output="page")
+ ) ),
+ rdsf(300)
+ )
[1] TRUE
> all.equal(
+ as.character(
+ diffPrint(
+ letters[1:6], LETTERS[1:6], mode="unified",
+ style=StyleHtmlLightYb(html.output="page")
+ ) ),
+ rdsf(350)
+ )
[1] TRUE
> # - Sub CSS --------------------------------------------------------------------
>
> # Mess up the CSS to test that we can change CSS file
>
> local({
+ f <- tempfile()
+ on.exit(unlink(f))
+ cat("div.row {background-color: red;}\n", file=f)
+ all.equal(
+ as.character(
+ diffPrint(
+ letters, LETTERS,
+ style=StyleHtmlLightYb(css=f, html.output="diff.w.style")
+ )
+ ),
+ rdsf(400)
+ )
+ })
[1] TRUE
> # - Tag funs -------------------------------------------------------------------
>
> div_a <- div_f("A", c(color="red"))
> all.equal(
+ div_a(c("a", "b")),
+ c(
+ "<div class='A' style='color: red;'>a</div>",
+ "<div class='A' style='color: red;'>b</div>"
+ )
+ )
[1] TRUE
> span_a <- span_f()
> all.equal(span_a(c("a", "b")), c("<span>a</span>", "<span>b</span>"))
[1] TRUE
>
> try(div_a(TRUE)) # "must be character"
Error in div_a(TRUE) : Argument `x` must be character.
> all.equal(div_a(character()),character())
[1] TRUE
>
> # - nchar ----------------------------------------------------------------------
>
> all.equal(nchar_html("<a href='blahblah'>25</a>"), 2)
[1] TRUE
> all.equal(nchar_html("<a href='blahblah'>25 </a>"), 3)
[1] TRUE
>
> # - cont_f ---------------------------------------------------------------------
>
> try(cont_f("hello")(1:3)) # "must be character"
Error in cont_f("hello")(1:3) : Argument `x` must be character.
>
> proc.time()
user system elapsed
1.416 0.133 1.555
|