document

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

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

Document represents a chunk of Markdown text in UTF-8 as HTML.

func (*Document) Borrow

func (d *Document) Borrow(fn func(content string))

Borrow allows access to the underlying document content. buf should not be retained outside of fn.

func (*Document) Convert

func (d *Document) Convert(text []byte, md goldmark.Markdown) error

Convert converts the given Markdown text to HTML.

func (*Document) Title

func (d *Document) Title() string

Title returns the document title, if any.

type Index

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

Index is a map of file paths to documents.

func NewIndex

func NewIndex() *Index

NewIndex creates a new index.

func (*Index) Add

func (idx *Index) Add(file string) *Document

Add creates a new document in the index. If the file path exists, the existing document is returned.

func (*Index) Get

func (idx *Index) Get(file string) *Document

Get returns the document mapped to the file path.

func (*Index) Has

func (idx *Index) Has(file string) bool

Has checks if the index contains the file path.

func (*Index) Remove

func (idx *Index) Remove(file string)

Remove deletes the document mapped to the file path.

type Library

type Library struct {
	*Index
	// contains filtered or unexported fields
}

Library is an index of documents backed by a source.

func NewLibrary

func NewLibrary(src source.Source, md goldmark.Markdown) *Library

NewLibrary creates a new library with the given source and Markdown converter.

func (*Library) Close

func (l *Library) Close() error

Close closes the library.

func (*Library) Reload

func (l *Library) Reload(file string) error

Reload refreshes the content of a document given its file path.

func (*Library) Watch

func (l *Library) Watch(logger *log.Logger)

Watch begins watching the library's source for changes. Errors are logged with the given logger.

Jump to

Keyboard shortcuts

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