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:
parent
919b1f5b9b
commit
792d134042
2
go.mod
2
go.mod
@ -1,3 +1 @@
|
|||||||
module github.com/russross/blackfriday/v2
|
module github.com/russross/blackfriday/v2
|
||||||
|
|
||||||
require github.com/pmezard/go-difflib v1.0.0
|
|
||||||
|
2
go.sum
2
go.sum
@ -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=
|
|
@ -14,12 +14,12 @@
|
|||||||
package blackfriday
|
package blackfriday
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/pmezard/go-difflib/difflib"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestParams struct {
|
type TestParams struct {
|
||||||
@ -187,12 +187,22 @@ func doTestsReference(t *testing.T, files []string, flag Extensions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doTestDiff(name, expected, actual string) string {
|
func doTestDiff(name, expected, actual string) string {
|
||||||
d, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
|
expectedLines := strings.Split(expected, "\n")
|
||||||
A: difflib.SplitLines(expected),
|
actualLines := strings.Split(actual, "\n")
|
||||||
B: difflib.SplitLines(actual),
|
d := "file: " + name + "\n"
|
||||||
FromFile: "expect: " + name,
|
for i, line := range expectedLines {
|
||||||
ToFile: "actual: " + name,
|
// Allow the actualLines indexing to panic because we're in tests where
|
||||||
Context: 1,
|
// 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
|
return d
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user