Skip to content

support image lazyload and more customize attribute.

License

Notifications You must be signed in to change notification settings

fundipper/goldmark-images

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

support image lazyload and more customize attribute.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages