html <-function(x) structure(x, class ="advr_html")#dispatchprint.advr_html <-function(x, ...) { out <-paste0("<HTML> ", x)cat(paste(strwrap(out), collapse ="\n"), "\n", sep ="")}
21.3.2 Generic
escape <-function(x) UseMethod("escape")escape.character <-function(x) { x <-gsub("&", "&", x) x <-gsub("<", "<", x) x <-gsub(">", ">", x)html(x)}escape.advr_html <-function(x) x
21.3.3 Checks
escape("This is some text.")#> <HTML> This is some text.escape("x > 1 & y < 2")#> <HTML> x > 1 & y < 2escape(escape("This is some text. 1 > 2")) #double escape#> <HTML> This is some text. 1 > 2escape(html("<hr />")) #already html#> <HTML> <hr />