From 2ee11632f475764a30cac742e65c7fd82b78cf96 Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Sat, 18 Nov 2017 11:02:52 +0900 Subject: [PATCH] Use blackfriday as markdown parser --- examples/markdown.feature | 13 +++++++++++++ main.go | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/markdown.feature b/examples/markdown.feature index 838a707..9dbc813 100644 --- a/examples/markdown.feature +++ b/examples/markdown.feature @@ -80,3 +80,16 @@ Feature: Markdown """ When I successfully run `linkcheck foo.md bar.md` Then the stdout should contain exactly "" + + Scenario: Check 2 markdown files + Given a file named "foo.md" with: + """ + [![Circle CI](https://img.shields.io/circleci/project/github/raviqqe/linkcheck.svg?style=flat-square)](https://circleci.com/gh/raviqqe/linkcheck) + [![Go Report Card](https://goreportcard.com/badge/github.com/raviqqe/linkcheck?style=flat-square)](https://goreportcard.com/report/github.com/raviqqe/linkcheck) + """ + And a file named "foo.sh" with: + """ + linkcheck -v foo.md 2>&1 | wc -l + """ + When I successfully run `sh foo.sh` + Then the stdout should contain exactly "2" diff --git a/main.go b/main.go index d87cf86..7102ba5 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,15 @@ package main import ( + "bytes" "io/ioutil" "net/url" "os" - "strings" "time" - "github.com/a8m/mark" "github.com/docopt/docopt-go" "golang.org/x/net/html" + blackfriday "gopkg.in/russross/blackfriday.v2" ) func main() { @@ -50,7 +50,7 @@ func checkFile(c urlChecker, f string) bool { return false } - n, err := html.Parse(strings.NewReader(mark.Render(string(bs)))) + n, err := html.Parse(bytes.NewReader(blackfriday.Run(bs))) if err != nil { printToStderr(err.Error())