Browse Source

Check images

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

2
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"

24
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] <filenames>...
Options:
Options:
-v, --verbose Be verbose`
args, err := docopt.Parse(usage, nil, true, "linkcheck", true)

Loading…
Cancel
Save