Fast Link Checker for Markdown and HTML in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
685 B

package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/a8m/mark"
docopt "github.com/docopt/docopt-go"
"golang.org/x/net/html"
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintln(os.Stderr, r.(error).Error())
os.Exit(1)
}
}()
args := getArgs()
bs, err := ioutil.ReadFile(args["<filename>"].(string))
if err != nil {
panic(err)
}
html.Parse(strings.NewReader(mark.Render(string(bs))))
}
func getArgs() map[string]interface{} {
usage := `Link checker for Markdown and HTML
Usage:
linkcheck <filename>`
args, err := docopt.Parse(usage, nil, true, "linkcheck", true)
if err != nil {
panic(err)
}
return args
}