markdown

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() goldmark.Markdown

func Trim

func Trim(markdown []byte) ([]byte, error)

Types

type Collection

type Collection struct {
	// contains filtered or unexported fields
}

func (*Collection) Description

func (c *Collection) Description() string

Description implements model.Collection.

func (*Collection) ID

func (c *Collection) ID() model.CollectionID

ID implements model.Collection.

func (*Collection) Label

func (c *Collection) Label() string

Label implements model.Collection.

type Document

type Document struct {
	// contains filtered or unexported fields
}

func Parse

func Parse(data []byte, funcs ...OptionFunc) (*Document, error)

func (*Document) AddCollection

func (d *Document) AddCollection(coll model.Collection)

func (*Document) Chunk

func (d *Document) Chunk(start int, end int) ([]byte, error)

Chunk implements model.Document.

func (*Document) Collections

func (d *Document) Collections() []model.Collection

Collections implements model.Document.

func (*Document) Content

func (d *Document) Content() ([]byte, error)

Content implements model.Document.

func (*Document) ETag

func (d *Document) ETag() string

ETag implements model.Document.

func (*Document) ID

func (d *Document) ID() model.DocumentID

ID implements model.Document.

func (*Document) Metadata added in v0.0.3

func (d *Document) Metadata() map[string]any

Metadata implements model.WithMetadata.

func (*Document) Sections

func (d *Document) Sections() []model.Section

Sections implements model.Document.

func (*Document) SetETag

func (d *Document) SetETag(etag string)

func (*Document) SetMetadata added in v0.0.3

func (d *Document) SetMetadata(metadata map[string]any)

SetMetadata attaches arbitrary metadata used for filtering at search time.

func (*Document) SetSource

func (d *Document) SetSource(source *url.URL)

func (*Document) Source

func (d *Document) Source() *url.URL

Source implements model.Document.

type NodeTransformer

type NodeTransformer interface {
	Transform(n ast.Node) error
}

type NodeTransformerFunc

type NodeTransformerFunc func(n ast.Node) error
var StripDataURL NodeTransformerFunc = func(n ast.Node) error {
	stripDataURL := func(destination []byte) []byte {
		if strings.HasPrefix(string(destination), "data:") {
			destination = []byte("#stripped")
		}
		return destination
	}

	switch typ := n.(type) {
	case *ast.Image:
		typ.Destination = stripDataURL(typ.Destination)
	case *ast.Link:
		typ.Destination = stripDataURL(typ.Destination)
	}

	return nil
}

func (NodeTransformerFunc) Transform

func (f NodeTransformerFunc) Transform(n ast.Node) error

type OptionFunc

type OptionFunc func(opts *Options)

func WithMaxWordPerSection

func WithMaxWordPerSection(maxWord int) OptionFunc

func WithNodeTransformers

func WithNodeTransformers(transformers ...NodeTransformer) OptionFunc

type Options

type Options struct {
	MaxWordPerSection int
	Transformers      []NodeTransformer
}

func NewOptions

func NewOptions(funcs ...OptionFunc) *Options

type Section

type Section struct {
	// contains filtered or unexported fields
}

func (*Section) AppendRange

func (s *Section) AppendRange(end int)

func (*Section) Branch

func (s *Section) Branch() []model.SectionID

Branch implements model.Section.

func (*Section) Content

func (s *Section) Content() ([]byte, error)

Content implements model.Section.

func (*Section) Document

func (s *Section) Document() model.Document

Document implements model.Section.

func (*Section) End

func (s *Section) End() int

End implements model.Section.

func (*Section) ID

func (s *Section) ID() model.SectionID

ID implements model.Section.

func (*Section) Level

func (s *Section) Level() uint

Level implements model.Section.

func (*Section) Parent

func (s *Section) Parent() model.Section

Parent implements model.Section.

func (*Section) Sections

func (s *Section) Sections() []model.Section

Sections implements model.Section.

func (*Section) Start

func (s *Section) Start() int

Start implements model.Section.

type Transformer

type Transformer struct {
	// contains filtered or unexported fields
}

func (*Transformer) Error

func (t *Transformer) Error() error

func (*Transformer) Transform

func (t *Transformer) Transform(root *ast.Document, reader text.Reader, pc parser.Context)

Jump to

Keyboard shortcuts

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