Browse Source

Check images

renovate/configure
Yota Toyama 8 years ago
parent
commit
3b83424073
  1. 2
      examples/markdown.feature
  2. 12
      main.go

2
examples/markdown.feature

@ -92,4 +92,4 @@ Feature: Markdown
linkcheck -v foo.md 2>&1 | wc -l linkcheck -v foo.md 2>&1 | wc -l
""" """
When I successfully run `sh foo.sh` When I successfully run `sh foo.sh`
Then the stdout should contain exactly "2" Then the stdout should contain exactly "4"

12
main.go

@ -49,13 +49,23 @@ func extractURLs(n *html.Node) []string {
n := ns[i] n := ns[i]
ns = ns[:i] ns = ns[:i]
if n.Type == html.ElementNode && n.Data == "a" { if n.Type == html.ElementNode {
switch n.Data {
case "a":
for _, a := range n.Attr { for _, a := range n.Attr {
if a.Key == "href" && isURL(a.Val) { if a.Key == "href" && isURL(a.Val) {
ss[a.Val] = true ss[a.Val] = true
break break
} }
} }
case "img":
for _, a := range n.Attr {
if a.Key == "src" && isURL(a.Val) {
ss[a.Val] = true
break
}
}
}
} }
for n := n.FirstChild; n != nil; n = n.NextSibling { for n := n.FirstChild; n != nil; n = n.NextSibling {

Loading…
Cancel
Save