Skip to content

Commit 99b1048

Browse files
committed
Update to github.com/russross/blackfriday/v2
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
1 parent 72acd4d commit 99b1048

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

schema/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ go 1.21
88
require (
99
github.com/opencontainers/go-digest v1.0.0
1010
github.com/opencontainers/image-spec v1.1.1
11-
github.com/russross/blackfriday v1.6.0
11+
github.com/russross/blackfriday/v2 v2.1.0
1212
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1
1313
)
1414

schema/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK
22
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
33
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
44
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
5-
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
6-
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
5+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
6+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
77
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw=
88
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
99
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=

schema/spec_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"testing"
2828

2929
"github.com/opencontainers/image-spec/schema"
30-
"github.com/russross/blackfriday"
30+
"github.com/russross/blackfriday/v2"
3131
)
3232

3333
var (
@@ -120,9 +120,12 @@ type renderer struct {
120120
fn func(text []byte, lang string)
121121
}
122122

123-
func (r *renderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
124-
r.fn(text, lang)
125-
r.Renderer.BlockCode(out, text, lang)
123+
func (r *renderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
124+
if node.Type == blackfriday.CodeBlock {
125+
lang := bytes.TrimRight(node.Info, "\t ")
126+
r.fn(node.Literal, string(lang))
127+
}
128+
return r.Renderer.RenderNode(w, node, entering)
126129
}
127130

128131
type example struct {
@@ -174,7 +177,7 @@ func extractExamples(rd io.Reader) ([]example, error) {
174177

175178
var examples []example
176179
renderer := &renderer{
177-
Renderer: blackfriday.HtmlRenderer(0, "test test", ""),
180+
Renderer: blackfriday.NewHTMLRenderer(blackfriday.HTMLRendererParameters{}),
178181
fn: func(text []byte, lang string) {
179182
examples = append(examples, parseExample(lang, string(text)))
180183
},
@@ -184,9 +187,9 @@ func extractExamples(rd io.Reader) ([]example, error) {
184187
// the side-effect of calling back for each code block.
185188
// TODO(stevvooe): Consider just parsing these with a scanner. It will be
186189
// faster and we can retain file, line no.
187-
blackfriday.MarkdownOptions(p, renderer, blackfriday.Options{
188-
Extensions: blackfriday.EXTENSION_FENCED_CODE,
189-
})
190+
_ = blackfriday.Run(p,
191+
blackfriday.WithRenderer(renderer),
192+
blackfriday.WithExtensions(blackfriday.FencedCode))
190193

191194
return examples, nil
192195
}

0 commit comments

Comments
 (0)