Skip to content

An extention of goldmark to embed local images into a rendered html file as base64 encoded data.

License

Notifications You must be signed in to change notification settings

tenkoh/goldmark-img64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goldmark-img64

An extention of goldmark to embed local images into a rendered html file as base64 encoded data.

![alt](./image.png "title")
<p><img src="data:image/png;base64,..." alt="alt" title="title"></p>

Installation

go get github.com/tenkoh/goldmark-img64

Quick usage

When your target markdown file is in the current working directory, just do as below.

package main

import (
    "io"
    "os"

    "github.com/yuin/goldmark"
    img64 "github.com/tenkoh/goldmark-img64"
)

func main() {
    f, _ := os.Open("target.md")
    defer f.Close()
    b, _ := io.ReadAll(f)
    goldmark.New(goldmark.WithExtensions(img64.Img64)).Convert(b, os.Stdout)
}

When your target markdown is not in the current working directory, add WithParentPath option.

goldmark.New(
    goldmark.WithExtensions(img64.Img64),
    goldmark.WithRendererOptions(img64.WithParentPath(dir)),
)

This package supports these image types.

  • "image/apng"
  • "image/avif"
  • "image/gif"
  • "image/jpeg"
  • "image/png"
  • "image/svg+xml"
  • "image/webp"

License

MIT

Author

tenkoh

About

An extention of goldmark to embed local images into a rendered html file as base64 encoded data.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages