Skip to content

Files

Latest commit

0dd2732 · Apr 15, 2022

History

History
42 lines (31 loc) · 818 Bytes

README.md

File metadata and controls

42 lines (31 loc) · 818 Bytes

goldmark-images

Goldmark image replacer extension, base on mdigger/goldmark-images.

support image lazyload and more customize attribute.

code

var source = []byte(`![alt](image.png "title")`)

func Example() {
	md := goldmark.New(
		goldmark.WithExtensions(
			images.NewExtender(
				"/loading.gif", // source
				"data-src",    // target
				map[string]string{
					"class": "lazy", // arrtibute
				}),
		),
	)
	if err := md.Convert(source, os.Stdout); err != nil {
		log.Fatal(err)
	}
}

view

<p>
<img src="/loading.gif" alt="alt" title="title" class="lazy" data-src="image.png">
</p>

thanks

Goldmark

mdigger