Browse Source

Use blackfriday as markdown parser

renovate/configure
Yota Toyama 8 years ago
parent
commit
2ee11632f4
  1. 13
      examples/markdown.feature
  2. 6
      main.go

13
examples/markdown.feature

@ -80,3 +80,16 @@ Feature: Markdown
""" """
When I successfully run `linkcheck foo.md bar.md` When I successfully run `linkcheck foo.md bar.md`
Then the stdout should contain exactly "" 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"

6
main.go

@ -1,15 +1,15 @@
package main package main
import ( import (
"bytes"
"io/ioutil" "io/ioutil"
"net/url" "net/url"
"os" "os"
"strings"
"time" "time"
"github.com/a8m/mark"
"github.com/docopt/docopt-go" "github.com/docopt/docopt-go"
"golang.org/x/net/html" "golang.org/x/net/html"
blackfriday "gopkg.in/russross/blackfriday.v2"
) )
func main() { func main() {
@ -50,7 +50,7 @@ func checkFile(c urlChecker, f string) bool {
return false return false
} }
n, err := html.Parse(strings.NewReader(mark.Render(string(bs)))) n, err := html.Parse(bytes.NewReader(blackfriday.Run(bs)))
if err != nil { if err != nil {
printToStderr(err.Error()) printToStderr(err.Error())

Loading…
Cancel
Save