Documentation ¶
Index ¶
- func RenderWYSIWYG(ctx context.Context, buffer *gtk.TextBuffer)
- func SetIter(iter *gtk.TextIter, src []byte, byteOffset int)
- func WithState(ctx context.Context, state *block.ContainerState) context.Context
- type MarkdownViewer
- type OptionFunc
- type Renderer
- func (r *Renderer) InsertSegments(text *block.TextBlock, segs *text.Segments)
- func (r *Renderer) Render(ctx context.Context, n ast.Node) ast.WalkStatus
- func (r *Renderer) RenderChildren(ctx context.Context, n ast.Node) ast.WalkStatus
- func (r *Renderer) RenderChildrenWithTag(ctx context.Context, n ast.Node, tagName string) ast.WalkStatus
- func (r *Renderer) RenderOnce(ctx context.Context, n ast.Node) ast.WalkStatus
- func (r *Renderer) RenderSiblings(ctx context.Context, first ast.Node) ast.WalkStatus
- func (r *Renderer) Source() []byte
- func (r *Renderer) State(ctx context.Context) *block.ContainerState
- type RendererFunc
- type WYSIWYG
- func (w *WYSIWYG) BoundIsInvisible() bool
- func (w *WYSIWYG) MarkBounds(i, j int, names ...string)
- func (w *WYSIWYG) MarkText(n ast.Node, names ...string)
- func (w *WYSIWYG) MarkTextFunc(n ast.Node, names []string, f func(h, t *gtk.TextIter))
- func (w *WYSIWYG) MarkTextTags(n ast.Node, tags ...*gtk.TextTag)
- func (w *WYSIWYG) MarkTextTagsFunc(n ast.Node, tags []*gtk.TextTag, f func(h, t *gtk.TextIter))
- func (w *WYSIWYG) Render()
- func (w *WYSIWYG) SetIter(iter *gtk.TextIter, byteOffset int)
- type WYSIWYGOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderWYSIWYG ¶
RenderWYSIWYG is a convenient function.
Types ¶
type MarkdownViewer ¶
MarkdownViewer extends a block.Viewer to view Markdown. A Markdown viewer is immutable.
func NewMarkdownViewer ¶
func NewMarkdownViewer(ctx context.Context, src []byte, n ast.Node, opts ...OptionFunc) *MarkdownViewer
NewMarkdownViewer creates a new MarkdownViewer.
type OptionFunc ¶
type OptionFunc func(r *Renderer)
OptionFunc is a function type for any options that modify Renderer's internals.
func WithFallbackRenderer ¶
func WithFallbackRenderer(renderer RendererFunc) OptionFunc
WithFallbackRenderer adds a new renderer that is called on any unhandled or unknown node.
func WithRenderer ¶
func WithRenderer(kind ast.NodeKind, renderer RendererFunc) OptionFunc
WithRenderer adds a new renderer.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is a rendering instance.
func NewRenderer ¶
func NewRenderer(src []byte, state *block.ContainerState, opts ...OptionFunc) *Renderer
NewRenderer creates a new renderer.
func (*Renderer) InsertSegments ¶
InsertSegments inserts the given text segments into the buffer.
func (*Renderer) RenderChildren ¶
RenderChildren renders all of n's children.
func (*Renderer) RenderChildrenWithTag ¶
func (r *Renderer) RenderChildrenWithTag(ctx context.Context, n ast.Node, tagName string) ast.WalkStatus
RenderChildrenWithTag calls RenderChildren wrapped within the given tag.
func (*Renderer) RenderOnce ¶
RenderOnce renders a single node.
func (*Renderer) RenderSiblings ¶
RenderSiblings renders all siblings in n and returns SkipChildren if everything is successfully rendered.
type RendererFunc ¶
RendererFunc is a map of callbacks for handling each ast.Node.
type WYSIWYG ¶
type WYSIWYG struct { Buffer *gtk.TextBuffer Tags *gtk.TextTagTable Source []byte Head *gtk.TextIter Tail *gtk.TextIter // contains filtered or unexported fields }
wysiwyg is the What-You-See-Is-What-You-Get node walker/highlighter.
func NewWYSIWYG ¶
func NewWYSIWYG(ctx context.Context, buffer *gtk.TextBuffer, opts WYSIWYGOpts) *WYSIWYG
NewWYSIWYG creates a new instance of WYSIWYG.
func (*WYSIWYG) BoundIsInvisible ¶
BoundIsInvisible returns true if the iterators are surrounding regions of texts that are invisible.
func (*WYSIWYG) MarkBounds ¶
MarkBounds is like MarkText, except it takes custom bounds instead of ones from an ast.Node.
func (*WYSIWYG) MarkText ¶
MarkText walks n's children and marks all its ast.Texts with the given tag.
func (*WYSIWYG) MarkTextFunc ¶
MarkTextFunc is similar to markText, except the caller has control over the head and tail iterators before the tags are applied. This is useful for block elements.
func (*WYSIWYG) MarkTextTags ¶
MarkTextTags is the tag variant of markText.
func (*WYSIWYG) MarkTextTagsFunc ¶
MarkTextTagsFunc is the tag variant of markTextFunc.