1
0
mirror of https://github.com/danog/blackfriday.git synced 2024-11-30 04:29:13 +01:00

Remove dep on umaintained difflib (#515)

This commit is contained in:
Sam Whited 2019-01-21 08:05:15 +00:00 committed by Vytautas Šaltenis
parent 919b1f5b9b
commit 792d134042
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
}