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`
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
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())

Loading…
Cancel
Save