Revision c5d145673d3feb15d9c872aea3be3647966d1a4f authored by ORPHANED on 19 June 2017, 11:43:32 UTC, committed by cran-robot on 19 June 2017, 11:43:32 UTC
1 parent 3152619
big_checkLinks.R
library(XML)
checkHTMLDocLinks =
function(fileName)
{
doc = htmlParse(fileName, error = function(...){})
href = unlist(getNodeSet(doc, "//a/@href"))
ng = grep("^(#|/|http|ftp|mailto)", href, invert = TRUE, value = TRUE)
ex = file.exists(ng)
ans = list(href = character(), object = character())
if(!all(ex)) {
ans$href = ng[!ex]
}
refs = unlist(getNodeSet(doc, "//object/@data|//embed/@src"))
ex = file.exists(refs)
if(!all(ex))
ans$object = refs[!ex]
internal = gsub("^#", "", grep("^#", href, value = TRUE))
anchors = unlist(getNodeSet(doc, "//*/@id"))
ans$internal = setdiff(internal, anchors)
src = unlist(getNodeSet(doc, "//*/@src"))
lsrc = grep("^(http|ftp)", src, invert = TRUE, value = TRUE)
ex = file.exists(lsrc)
ans$src = lsrc[!ex]
structure(ans, class = "MissingLinks")
}
Computing file changes ...