Home

Awesome

goldmark-embed

goldmark-embed is an extension for the goldmark library that extends the Markdown ![]() image embed syntax to support additional media formats.

YouTube only at first.

Demo

This markdown:

# Hello goldmark-embed

![](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

Becomes this HTML:

<h1>Hello goldmark-embed</h1>
<p><iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe></p>

Installation

go get github.com/13rac1/goldmark-embed

Usage

  markdown := goldmark.New(
    goldmark.WithExtensions(
      embed.Embed,
    ),
  )
  var buf bytes.Buffer
  if err := markdown.Convert([]byte(source), &buf); err != nil {
    panic(err)
  }
  fmt.Print(buf)
}

TODO

License

MIT

Author

Brad Erickson