markdown

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDepth = 6

Variables

View Source
var (
	KindGnoColumn       = ast.NewNodeKind("GnoColumn")
	GnoColumnsShorthand = []byte("|||") // shorthand for column separator
)
View Source
var (
	ErrFormUnexpectedOrInvalidTag = errors.New("unexpected or invalid tag")
	ErrFormInputMissingName       = errors.New(tagGnoInput + " must have a 'name' attribute")
	ErrFormInvalidInputType       = errors.New("invalid input type")
	ErrFormInputNameAlreadyUsed   = errors.New("input name already used")
)
View Source
var ErrLinkInvalidURL = errors.New("invalid URL format")

Error messages for invalid link formats

View Source
var ExtAlerts = &alertExtension{}

ExtAlerts is the global instance of the alert extension

View Source
var ExtColumns = &columns{}

ExtColumns instance for extending markdown with column functionality.

View Source
var ExtForms = &formExtension{}
View Source
var ExtImageValidator = &imgValidatorExtension{}

ExtImageValidator is a Goldmark extension that pre validation on image URLs.

View Source
var ExtLinks = &linkExtension{}

ExtLinks instance for extending markdown with link functionality

View Source
var ExtMention = &mentionExtension{}

ExtMention is the exported extension instance.

View Source
var KindAlert = ast.NewNodeKind("Alert")

KindAlert is the node kind identifier for Alert nodes

View Source
var KindAlertHeader = ast.NewNodeKind("AlertHeader")

KindAlertHeader is the node kind identifier for AlertHeader nodes

View Source
var KindForm = ast.NewNodeKind("Form")
View Source
var KindGnoLink = ast.NewNodeKind("GnoLink")

Functions

func ExtractAttr

func ExtractAttr(attrs []html.Attribute, key string) (val string, ok bool)

func GetWordArticle

func GetWordArticle(word string) string

GetWordArticle returns "a" or "an" based on the first letter of the word

func HTMLEscapeString

func HTMLEscapeString(s string) string

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 NewFormParser

func NewFormParser() *formParser

NewFormParser creates a new instance of formParser

func NewFormRenderer

func NewFormRenderer() *formRenderer

NewFormRenderer creates a new instance of formRenderer

func NewGnoParserContext

func NewGnoParserContext(url *weburl.GnoURL) 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

func ParseHTMLTokens

func ParseHTMLTokens(r io.Reader) ([]html.Token, error)

ParseHTMLTokens parses an HTML stream and returns a slice of html.Token. It stops at EOF or on error.

Types

type Alert

type Alert struct {
	ast.BaseBlock
}

Alert represents a block-level alert element in markdown It can contain a header and content, and supports different alert types

func NewAlert

func NewAlert() *Alert

NewAlert creates a new Alert node

func (*Alert) Dump

func (n *Alert) Dump(source []byte, level int)

Dump prints the AST structure for debugging purposes

func (*Alert) Kind

func (n *Alert) Kind() ast.NodeKind

Kind returns the node kind identifier

type AlertHTMLRenderer

type AlertHTMLRenderer struct {
	html.Config
}

AlertHTMLRenderer implements the HTML renderer for Alert nodes

func (*AlertHTMLRenderer) RegisterFuncs

RegisterFuncs registers the render functions

type AlertHeader

type AlertHeader struct {
	ast.BaseBlock
}

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

type AlertHeaderHTMLRenderer struct {
	html.Config
}

AlertHeaderHTMLRenderer implements the HTML renderer for AlertHeader nodes

func (*AlertHeaderHTMLRenderer) RegisterFuncs

RegisterFuncs registers the render functions

type AlertType

type AlertType int
const (
	AlertTypeNote AlertType = iota
	AlertTypeTip
	AlertTypeCaution
	AlertTypeWarning
	AlertTypeSuccess
	AlertTypeInfo
)

type FormElement

type FormElement interface {
	GetError() error
}

FormElement interface for form elements

type FormInput

type FormInput struct {
	Error       error
	Name        string
	Type        string
	Placeholder string
	Value       string // For radio/checkbox values
	Checked     bool   // For radio/checkbox checked state
	Description string // New attribute for description span
}

func (*FormInput) GetError

func (in *FormInput) GetError() error

func (FormInput) String

func (in FormInput) String() string

type FormNode

type FormNode struct {
	ast.BaseBlock
	Error        error
	Elements     []FormElement
	ElementsName map[string]bool
	RenderPath   string // Path to render after form submission
	RealmName    string
}

func NewFormNode

func NewFormNode() *FormNode

func (*FormNode) Dump

func (n *FormNode) Dump(source []byte, level int)

Dump displays the information level for the Form node

func (*FormNode) Kind

func (n *FormNode) Kind() ast.NodeKind

func (*FormNode) NewErrorInput

func (n *FormNode) NewErrorInput(err error) (input *FormInput)

func (*FormNode) NewErrorSelect

func (n *FormNode) NewErrorSelect(err error) (sel *FormSelect)

func (*FormNode) NewErrorTextarea

func (n *FormNode) NewErrorTextarea(err error) (textarea *FormTextarea)

func (*FormNode) NewInput

func (n *FormNode) NewInput() (input *FormInput)

func (*FormNode) NewSelect

func (n *FormNode) NewSelect() (sel *FormSelect)

func (*FormNode) NewTextarea

func (n *FormNode) NewTextarea() (textarea *FormTextarea)

type FormSelect

type FormSelect struct {
	Error       error
	Name        string
	Value       string // Value and display text for this option
	Selected    bool   // Whether this option is selected
	Description string // New attribute for description span
}

func (*FormSelect) GetError

func (sel *FormSelect) GetError() error

func (FormSelect) String

func (sel FormSelect) String() string

type FormTextarea

type FormTextarea struct {
	Error       error
	Name        string
	Placeholder string
	Rows        int
	Description string // New attribute for description span
}

func (*FormTextarea) GetError

func (ta *FormTextarea) GetError() error

func (FormTextarea) String

func (ta FormTextarea) String() string

type GenFunc

type GenFunc func(t *testing.T, nameIn string, input []byte) (nameOut string, output []byte)

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) Kind

func (*GnoColumnNode) Kind() ast.NodeKind

Kind implements Node.Kind.

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 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 struct {
	*ast.Link
	LinkType GnoLinkType
	GnoURL   *weburl.GnoURL
}

GnoLink represents a link with Gno-specific metadata

func (*GnoLink) Dump

func (n *GnoLink) Dump(source []byte, level int)

func (*GnoLink) Kind

func (*GnoLink) Kind() ast.NodeKind

Kind implements Node.Kind.

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

type GoldenTests struct {
	Recurse      bool
	Update       bool
	GenerateFunc GenFunc
}

func NewGoldentTests

func NewGoldentTests(exec GenFunc) *GoldenTests

func (*GoldenTests) Run

func (g *GoldenTests) Run(t *testing.T, dir string)

type ImageValidatorFunc

type ImageValidatorFunc func(uri string) (ok bool)

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 Toc

type Toc struct {
	Items []*TocItem
}

func TocInspect

func TocInspect(n ast.Node, src []byte, opts TocOptions) (Toc, error)

type TocItem

type TocItem struct {
	// Title of this item in the table of contents.
	//
	// This may be blank for items that don't refer to a heading, and only
	// have sub-items.
	Title []byte

	// ID is the identifier for the heading that this item refers to. This
	// is the fragment portion of the link without the "#".
	//
	// This may be blank if the item doesn't have an id assigned to it, or
	// if it doesn't have a title.
	//
	// Enable AutoHeadingID in your parser if you expected these to be set
	// but they weren't.
	ID []byte

	// Items references children of this item.
	//
	// For a heading at level 3, Items, contains the headings at level 4
	// under that section.
	Items []*TocItem
}

func (TocItem) Anchor

func (i TocItem) Anchor() string

type TocOptions

type TocOptions struct {
	MinDepth, MaxDepth int
}

Jump to

Keyboard shortcuts

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