11 changed files with 99 additions and 22 deletions
@ -1,8 +1,16 @@ |
|||
language: R |
|||
sudo: false |
|||
sudo: required |
|||
cache: packages |
|||
|
|||
r: |
|||
- oldrel |
|||
- release |
|||
- devel |
|||
|
|||
notifications: |
|||
email: |
|||
- bob@rud.is |
|||
irc: |
|||
channels: |
|||
- "104.236.112.222#builds" |
|||
nick: travisci |
|||
|
@ -0,0 +1,17 @@ |
|||
#' @param encoding specify the encoding when tidying an \code{httr} \code{response} |
|||
#' object. Default to "\code{UTF-8}". |
|||
#' @export |
|||
#' @rdname tidy_html |
|||
tidy_html.response <- function(content, options=list(TidyXhtmlOut=TRUE), |
|||
verbose=FALSE, encoding="UTF-8") { |
|||
|
|||
if (!grepl("html", content$headers[["content-type"]])) { |
|||
stop("htmltidy only parses HTML content from httr::response objects", |
|||
call.=FALSE) |
|||
} |
|||
|
|||
html_txt <- httr::content(content, as="text", encoding=encoding) |
|||
|
|||
tidy_html(html_txt) |
|||
|
|||
} |
@ -1,7 +1,9 @@ |
|||
context("basic functionality") |
|||
test_that("tidying works", { |
|||
|
|||
expect_gte(nchar(tidy_html("<b><p><a href='http://google.com'>google ></a></p></b>")), |
|||
249) |
|||
th <- tidy_html("<b><p><a href='http://google.com'>google ></a></p></b>") |
|||
|
|||
expect_gte(nchar(th), 249) |
|||
expect_equivalent(grepl("HTML Tidy for HTML5 for R", th), TRUE) |
|||
|
|||
}) |
|||
|
Loading…
Reference in new issue