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/dchenk/go-render-quill
import "github.com/dchenk/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>
- Background color
- Bold
- Text color
- Italic
- Link
- Size
- Strikethrough
- Superscript/Subscript
- Underline
- Blockquote
- Header
- Indent
- List (ul and ol, including nested lists)
- Text alignment
- Code block
- Image (an inline format)
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
.