Video embed support
Closed this issue · 0 comments
emad-elsaid commented
I noticed the library doesn't support video embed. I overcome this limitation by using the following formatter
import (
"fmt"
"io"
"strconv"
quill_html "github.com/dchenk/go-render-quill"
)
func customFormats(keyword string, op *quill_html.Op) quill_html.Formatter {
if keyword == "video" {
return &VideoFormatter{link: op.Data}
}
return nil
}
type VideoFormatter struct {
link string
}
func (v *VideoFormatter) Fmt() *quill_html.Format {
return nil
}
func (v *VideoFormatter) HasFormat(op *quill_html.Op) bool {
return op.Type == "video"
}
func (v *VideoFormatter) Write(buf io.Writer) {
fmt.Fprintf(buf, `<iframe class="video" src=%s></iframe>`, strconv.Quote(v.link))
}
I use html, err := quill_html.RenderExtended([]byte(content), customFormats)
to render the video link inside an iframe. worked with youtube.
I couldn't edit the wiki so I thought it'll be useful to document it in the issues here.