Skip to content

Render Quill insert Delta operations to HTML

License

Notifications You must be signed in to change notification settings

temuera/go-render-quill

 
 

Repository files navigation

go-render-quill Build Status

Package quill takes a Quill-based Delta (https://github.com/quilljs/delta) as a JSON array of insert operations and renders the defined HTML document.

Complete documentation at GoDoc: https://godoc.org/github.com/dazhoudotnet/go-render-quill

Usage

import "github.com/dazhoudotnet/go-render-quill"

var delta = `[{"insert":"This "},{"attributes":{"italic":true},"insert":"is"},
    {"insert":" "},{"attributes":{"bold":true},"insert":"great!"},{"insert":"\n"}]`

html, err := quill.Render(delta)
if err != nil {
	panic(err)
}
fmt.Println(string(html))
// Output: <p>This <em>is</em> <strong>great!</strong></p>

Supported Formats

Inline

  • Background color
  • Bold
  • Text color
  • Italic
  • Link
  • Size
  • Strikethrough
  • Superscript/Subscript
  • Underline

Block

  • Blockquote
  • Header
  • Indent
  • List (ul and ol, including nested lists)
  • Text alignment
  • Code block

Embeds

  • Image (an inline format)

Extending

The simple Formatter interface is all you need to implement for most block and inline formats. Instead of Render use RenderExtended and provide a function that returns a Formatter for inserts that have the format you need.

For more control, you can also implement FormatWriter or FormatWrapper.

About

Render Quill insert Delta operations to HTML

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%