Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractAttr(attrs []html.Attribute, key string) (val string, ok bool)
- func GetWordArticle(word string) string
- func HTMLEscapeString(s string) string
- func NewAlertHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
- func NewAlertHeaderHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
- func NewAlertHeaderParser() parser.BlockParser
- func NewAlertParser() parser.BlockParser
- func NewGnoParserContext(mdctx GnoContext) parser.Context
- func NewMentionParser() parser.InlineParser
- func ParseHTMLTokens(r io.Reader) ([]html.Token, error)
- type Alert
- type AlertHTMLRenderer
- type AlertHeader
- type AlertHeaderHTMLRenderer
- type AlertType
- type FormElement
- type FormExtension
- type FormInput
- type FormNode
- type FormParser
- func (p *FormParser) CanAcceptIndentedLine() bool
- func (p *FormParser) CanInterruptParagraph() bool
- func (p *FormParser) Close(node ast.Node, reader text.Reader, pc parser.Context)
- func (p *FormParser) Continue(node ast.Node, reader text.Reader, pc parser.Context) parser.State
- func (p *FormParser) Open(parent ast.Node, reader text.Reader, pc parser.Context) (ast.Node, parser.State)
- func (p *FormParser) Trigger() []byte
- type FormRenderer
- type FormSelect
- type FormTextarea
- type GenFunc
- type GnoColumnNode
- type GnoColumnTag
- type GnoContext
- type GnoExtension
- type GnoLink
- type GnoLinkType
- type GoldenTests
- type ImageValidatorFunc
- type Option
- type Toc
- type TocOptions
Constants ¶
const MaxDepth = 6
Variables ¶
var ( KindGnoColumn = ast.NewNodeKind("GnoColumn") GnoColumnsShorthand = []byte("|||") // shorthand for column separator )
var ( ErrFormInvalidTag = errors.New("unexpected or invalid tag") ErrFormMissingName = errors.New("missing 'name' attribute") ErrFormInvalidInputType = errors.New("invalid input type") ErrFormDuplicateName = errors.New("name already used") ErrFormInvalidAttribute = errors.New("invalid attribute for input type") ErrFormMissingValue = errors.New("missing 'value' attribute") )
Form-specific errors
var ErrLinkInvalidURL = errors.New("invalid URL format")
Error messages for invalid link formats
var ExtAlerts = &alertExtension{}
ExtAlerts is the global instance of the alert extension
var ExtColumns = &columns{}
ExtColumns instance for extending markdown with column functionality.
var ExtForms = &FormExtension{}
ExtForms is the public form extension instance
var ExtImageValidator = &imgValidatorExtension{}
ExtImageValidator is a Goldmark extension that pre validation on image URLs.
var ExtLinks = &linkExtension{}
ExtLinks instance for extending markdown with link functionality
var ExtMention = &mentionExtension{}
ExtMention is the exported extension instance.
var (
FormKind = ast.NewNodeKind("Form")
)
var KindAlert = ast.NewNodeKind("Alert")
KindAlert is the node kind identifier for Alert nodes
var KindAlertHeader = ast.NewNodeKind("AlertHeader")
KindAlertHeader is the node kind identifier for AlertHeader nodes
var KindGnoLink = ast.NewNodeKind("GnoLink")
Functions ¶
func GetWordArticle ¶
GetWordArticle returns "a" or "an" based on the first letter of the word
func HTMLEscapeString ¶
HTMLEscapeString escapes special characters in HTML content
func NewAlertHTMLRenderer ¶
func NewAlertHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
NewAlertHTMLRenderer creates a new alert HTML renderer
func NewAlertHeaderHTMLRenderer ¶
func NewAlertHeaderHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
NewAlertHeaderHTMLRenderer creates a new alert header HTML renderer
func NewAlertHeaderParser ¶
func NewAlertHeaderParser() parser.BlockParser
NewAlertHeaderParser creates a new alert header parser
func NewAlertParser ¶
func NewAlertParser() parser.BlockParser
NewAlertParser creates a new alert parser
func NewGnoParserContext ¶
func NewGnoParserContext(mdctx GnoContext) parser.Context
NewGnoParserContext creates a new parser context with GnoURL
func NewMentionParser ¶
func NewMentionParser() parser.InlineParser
NewMentionParser creates a new parser for @ mentions and g1 addresses
Types ¶
type Alert ¶
Alert represents a block-level alert element in markdown It can contain a header and content, and supports different alert types
type AlertHTMLRenderer ¶
AlertHTMLRenderer implements the HTML renderer for Alert nodes
func (*AlertHTMLRenderer) RegisterFuncs ¶
func (r *AlertHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
RegisterFuncs registers the render functions
type AlertHeader ¶
AlertHeader represents the header part of an alert It contains the alert type and title
func NewAlertHeader ¶
func NewAlertHeader() *AlertHeader
NewAlertHeader creates a new AlertHeader node
func (*AlertHeader) Dump ¶
func (n *AlertHeader) Dump(source []byte, level int)
Dump prints the AST structure for debugging purposes
func (*AlertHeader) Kind ¶
func (n *AlertHeader) Kind() ast.NodeKind
Kind returns the node kind identifier
type AlertHeaderHTMLRenderer ¶
AlertHeaderHTMLRenderer implements the HTML renderer for AlertHeader nodes
func (*AlertHeaderHTMLRenderer) RegisterFuncs ¶
func (r *AlertHeaderHTMLRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
RegisterFuncs registers the render functions
type FormElement ¶
FormElement represents any form element
type FormExtension ¶
type FormExtension struct{}
FormExtension integrates forms into goldmark
func (*FormExtension) Extend ¶
func (e *FormExtension) Extend(m goldmark.Markdown)
type FormInput ¶
type FormInput struct {
Name string
Type string
Placeholder string
Value string
Checked bool
Readonly bool
Description string
Error error
}
FormInput represents an input element
type FormNode ¶
type FormNode struct {
ast.BaseBlock
Elements []FormElement
ExecFunc string // Function name for exec attribute
RenderPath string
RealmName string
Domain string
ChainId string
Remote string
Error error
// contains filtered or unexported fields
}
FormNode represents a form in the AST
type FormParser ¶
type FormParser struct{}
FormParser handles parsing of form blocks
func NewFormParser ¶
func NewFormParser() *FormParser
func (*FormParser) CanAcceptIndentedLine ¶
func (p *FormParser) CanAcceptIndentedLine() bool
func (*FormParser) CanInterruptParagraph ¶
func (p *FormParser) CanInterruptParagraph() bool
func (*FormParser) Trigger ¶
func (p *FormParser) Trigger() []byte
type FormRenderer ¶
type FormRenderer struct{}
FormRenderer handles rendering of form nodes
func NewFormRenderer ¶
func NewFormRenderer() *FormRenderer
func (*FormRenderer) RegisterFuncs ¶
func (r *FormRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)
type FormSelect ¶
type FormSelect struct {
Name string
Value string
Selected bool
Readonly bool
Description string
Error error
}
FormSelect represents a select option
func (FormSelect) GetError ¶
func (e FormSelect) GetError() error
func (FormSelect) GetName ¶
func (e FormSelect) GetName() string
func (FormSelect) String ¶
func (e FormSelect) String() string
type FormTextarea ¶
type FormTextarea struct {
Name string
Placeholder string
Rows int
Value string
Readonly bool
Description string
Error error
}
FormTextarea represents a textarea element
func (FormTextarea) GetError ¶
func (e FormTextarea) GetError() error
func (FormTextarea) GetName ¶
func (e FormTextarea) GetName() string
func (FormTextarea) String ¶
func (e FormTextarea) String() string
type GnoColumnNode ¶
type GnoColumnNode struct {
ast.BaseBlock
Index int // Index of the column associated with the node.
Tag GnoColumnTag // Current Column Tag for this node.
// contains filtered or unexported fields
}
GnoColumnNode represents a semantic tree for a "column".
func NewColumn ¶
func NewColumn(ctx *columnsContext, tag GnoColumnTag) *GnoColumnNode
NewColumn initializes a ColumnNode object.
func UndefinedGnoColumnNode ¶
func UndefinedGnoColumnNode() *GnoColumnNode
func (*GnoColumnNode) Dump ¶
func (n *GnoColumnNode) Dump(source []byte, level int)
Dump implements Node.Dump for debug representation.
func (*GnoColumnNode) IsEmptyColumns ¶
func (n *GnoColumnNode) IsEmptyColumns() bool
func (*GnoColumnNode) String ¶
func (n *GnoColumnNode) String() string
type GnoColumnTag ¶
type GnoColumnTag int
GnoColumnTag represents the type of tag in a column block.
const ( GnoColumnTagUndefined GnoColumnTag = iota GnoColumnTagOpen GnoColumnTagClose GnoColumnTagSep )
type GnoContext ¶
type GnoExtension ¶
type GnoExtension struct {
// contains filtered or unexported fields
}
func NewGnoExtension ¶
func NewGnoExtension(opts ...Option) *GnoExtension
func (*GnoExtension) Extend ¶
func (e *GnoExtension) Extend(m goldmark.Markdown)
Extend adds the Gno extension to the provided Goldmark markdown processor.
type GnoLink ¶
type GnoLink struct {
*ast.Link
LinkType GnoLinkType
GnoURL *weburl.GnoURL
}
GnoLink represents a link with Gno-specific metadata
type GnoLinkType ¶
type GnoLinkType int
GnoLinkType represents the type of a link
const ( GnoLinkTypeInvalid GnoLinkType = iota GnoLinkTypeExternal GnoLinkTypePackage GnoLinkTypeInternal GnoLinkTypeUser )
func (GnoLinkType) String ¶
func (t GnoLinkType) String() string
type GoldenTests ¶
func NewGoldentTests ¶
func NewGoldentTests(exec GenFunc) *GoldenTests
type ImageValidatorFunc ¶
ImageValidatorFunc validates image URLs. It should return `true` for any valid image URL.
type Option ¶
type Option func(cfg *config)
func WithImageValidator ¶
func WithImageValidator(valFunc ImageValidatorFunc) Option
type TocOptions ¶
type TocOptions struct {
MinDepth, MaxDepth int
}