diff --git a/examples/markdown.feature b/examples/markdown.feature index 9dbc813..4be900f 100644 --- a/examples/markdown.feature +++ b/examples/markdown.feature @@ -92,4 +92,4 @@ Feature: Markdown linkcheck -v foo.md 2>&1 | wc -l """ When I successfully run `sh foo.sh` - Then the stdout should contain exactly "2" + Then the stdout should contain exactly "4" diff --git a/main.go b/main.go index d1ef5b7..d7def67 100644 --- a/main.go +++ b/main.go @@ -49,11 +49,21 @@ func extractURLs(n *html.Node) []string { n := ns[i] ns = ns[:i] - if n.Type == html.ElementNode && n.Data == "a" { - for _, a := range n.Attr { - if a.Key == "href" && isURL(a.Val) { - ss[a.Val] = true - break + if n.Type == html.ElementNode { + switch n.Data { + case "a": + for _, a := range n.Attr { + if a.Key == "href" && isURL(a.Val) { + ss[a.Val] = true + break + } + } + case "img": + for _, a := range n.Attr { + if a.Key == "src" && isURL(a.Val) { + ss[a.Val] = true + break + } } } } @@ -74,10 +84,10 @@ func isURL(s string) bool { func getArgs() map[string]interface{} { usage := `Link checker for Markdown and HTML - Usage: +Usage: linkcheck [-v] ... - Options: +Options: -v, --verbose Be verbose` args, err := docopt.Parse(usage, nil, true, "linkcheck", true)