# NOT RUN {
opts <- list(
TidyDocType="html5",
TidyMakeClean=TRUE,
TidyHideComments=TRUE,
TidyIndentContent=TRUE,
TidyWrapLen=200
)
txt <- paste0(
c("<html><head><style>p { color: red; }</style><body><!-- ===== body ====== -->",
"<p>Test</p></body><!--Default Zone --> <!--Default Zone End--></html>"),
collapse="")
cat(tidy_html(txt, option=opts))
# }
# NOT RUN {
library(httr)
res <- GET("https://rud.is/test/untidy.html")
# look at the original, un-tidy source
cat(content(res, as="text", encoding="UTF-8"))
# see the tidied version
cat(tidy_html(content(res, as="text", encoding="UTF-8"),
list(TidyDocType="html5", TidyWrapLen=200)))
# but, you could also just do:
cat(tidy_html(url("https://rud.is/test/untidy.html")))
# }
Run the code above in your browser using DataLab