Categorygithub.com/PaperPrototype/goldmark-embed
modulepackage
0.0.0-20220504173457-3e5148e3bccc
Repository: https://github.com/paperprototype/goldmark-embed.git
Documentation: pkg.go.dev

# README

goldmark-embed

goldmark-embed is based on 13rac1's extension for the goldmark library that extends the Markdown ![]() image embed syntax to support additional media formats.

Supports YouTube and Vimeo links.

Demo

This markdown:

# Hello goldmark-embed for YouTube

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

# Hello goldmark-embed for Vimeo

![](https://vimeo.com/148751763)

Becomes this HTML:

<h1>Hello goldmark-embed for Youtube</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>
<h1>Hello goldmark-embed for Vimeo</h1>
<p><iframe src="https://player.vimeo.com/video/148751763?&amp;badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" width="724" height="404" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></p>

Installation

go get github.com/PaperPrototype/goldmark-embed

Usage

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

TODO

  • Embed Options
  • Additional Data Sources

License

MIT

Authors

Brad Erickson Abdiel Lopez

# Functions

New returns a new Embed extension.
NewHTMLRenderer builds a new HTMLRenderer with given options and returns it.
New Vimeo returns a new Vimeo node.
NewYouTube returns a new YouTube node.

# Variables

KindVimeo is a NodeKind of the Vimeo node.
KindYouTube is a NodeKind of the YouTube node.

# Structs

HTMLRenderer struct is a renderer.NodeRenderer implementation for the extension.
Vimeo struct represents a Vimeo Video embed of the markdown text.
YouTube struct represents a YouTube Video embed of the Markdown text.

# Type aliases

Option is a functional option type for this extension.