Remove dep on umaintained difflib

pull/515/head
Sam Whited 2019-01-01 09:26:23 -06:00
parent 919b1f5b9b
commit fa95cc8e62
3 changed files with 19 additions and 13 deletions

2
go.mod
View File

@ -1,3 +1 @@
module github.com/russross/blackfriday/v2
require github.com/pmezard/go-difflib v1.0.0

2
go.sum
View File

@ -1,2 +0,0 @@
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

View File

@ -14,12 +14,12 @@
package blackfriday
import (
"fmt"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"testing"
"github.com/pmezard/go-difflib/difflib"
)
type TestParams struct {
@ -187,12 +187,22 @@ func doTestsReference(t *testing.T, files []string, flag Extensions) {
}
func doTestDiff(name, expected, actual string) string {
d, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(expected),
B: difflib.SplitLines(actual),
FromFile: "expect: " + name,
ToFile: "actual: " + name,
Context: 1,
})
expectedLines := strings.Split(expected, "\n")
actualLines := strings.Split(actual, "\n")
d := "file: " + name + "\n"
for i, line := range expectedLines {
// Allow the actualLines indexing to panic because we're in tests where
// that's okay and we probably want to know about it if this input is wrong
// somehow.
if line != actualLines[i] {
d += fmt.Sprintf(`
line: %d
-%s
+%s
`, i, line, actualLines[i])
}
}
return d
}