all repos — grayfriday @ 792d13404204e12d4c292c77184f47ad325fcfdc

blackfriday fork with a few changes

Remove dep on umaintained difflib (#515)

Sam Whited sam@samwhited.com
Mon, 21 Jan 2019 08:05:15 +0000
commit

792d13404204e12d4c292c77184f47ad325fcfdc

parent

919b1f5b9bfe13933b93762ee39ea97de79039d9

3 files changed, 19 insertions(+), 13 deletions(-)

jump to
M go.modgo.mod

@@ -1,3 +1,1 @@

module github.com/russross/blackfriday/v2 - -require github.com/pmezard/go-difflib v1.0.0
D 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=
M helpers_test.gohelpers_test.go

@@ -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 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 }