blocks

package module
v0.0.0-...-19116e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(blocks []Block) string

Types

type Block

type Block struct {
	Type          BlockType `json:"type"`
	Children      []Block   `json:"children"`
	Text          *string   `json:"text"`
	Italic        *bool     `json:"italic"`
	Underline     *bool     `json:"underline"`
	Bold          *bool     `json:"bold"`
	StrikeThrough *bool     `json:"strikethrough"`
	Code          *bool     `json:"code"`
	Format        *string   `json:"format"`
	URL           *string   `json:"url"`
	Level         *int      `json:"level"`
	Image         *Image    `json:"image"`
}

func (Block) EmptyText

func (b Block) EmptyText() bool

type BlockType

type BlockType string
const BlockTypeCode BlockType = "code"
const BlockTypeHeading BlockType = "heading"
const BlockTypeImage BlockType = "image"
const BlockTypeLink BlockType = "link"
const BlockTypeList BlockType = "list"
const BlockTypeListItem BlockType = "list-item"
const BlockTypeParagraph BlockType = "paragraph"
const BlockTypeQuote BlockType = "quote"
const BlockTypeText BlockType = "text"

type CodeRenderer

type CodeRenderer interface {
	RenderCode(Block) string
}

type HeadingRenderer

type HeadingRenderer interface {
	RenderHeading(Block) string
}

type Image

type Image struct {
	Name            string `json:"name"`
	AlternativeText string `json:"alternativeText"`
	URL             string `json:"url"`
}

type ImageRenderer

type ImageRenderer interface {
	RenderImage(Block) string
}

type LinkRenderer

type LinkRenderer interface {
	RenderLink(Block) string
}

type ListFormat

type ListFormat string
const ListFormatOrdered ListFormat = "ordered"
const ListFormatUnordered ListFormat = "unordered"

type ListItemRenderer

type ListItemRenderer interface {
	RenderListItem(Block) string
}

type ListRenderer

type ListRenderer interface {
	RenderList(Block) string
}

type ParagraphRenderer

type ParagraphRenderer interface {
	RenderParagraph(Block) string
}

type QuoteRenderer

type QuoteRenderer interface {
	RenderQuote(Block) string
}

type Renderer

type Renderer struct {
	ParagraphRenderer ParagraphRenderer
	TextRenderer      TextRenderer
	ListRenderer      ListRenderer
	ListItemRenderer  ListItemRenderer
	HeadingRenderer   HeadingRenderer
	LinkRenderer      LinkRenderer
	ImageRenderer     ImageRenderer
	QuoteRenderer     QuoteRenderer
	CodeRenderer      CodeRenderer
}

func New

func New() *Renderer

func (*Renderer) Render

func (r *Renderer) Render(blocks []Block) string

func (*Renderer) RenderCode

func (r *Renderer) RenderCode(b Block) string

func (*Renderer) RenderHeading

func (r *Renderer) RenderHeading(b Block) string

func (*Renderer) RenderImage

func (r *Renderer) RenderImage(b Block) string
func (r *Renderer) RenderLink(b Block) string

func (*Renderer) RenderList

func (r *Renderer) RenderList(b Block) string

func (*Renderer) RenderListItem

func (r *Renderer) RenderListItem(b Block) string

func (*Renderer) RenderParagraph

func (r *Renderer) RenderParagraph(b Block) string

func (*Renderer) RenderQuote

func (r *Renderer) RenderQuote(b Block) string

func (*Renderer) RenderText

func (r *Renderer) RenderText(b Block) string

type TextRenderer

type TextRenderer interface {
	RenderText(Block) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL