document

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDocumentParser = newFailoverAttributeParser(
	[]attributeParser{
		&babikMLParser{},
	},
	&babikMLParser{},
)
View Source
var FutureDocumentParser = newFailoverAttributeParser(
	[]attributeParser{
		&jsonParser{},
		&babikMLParser{},
	},
	&jsonParser{},
)

todo(sebastian): make default in v2

Functions

func CountFinalLineBreaks added in v1.2.3

func CountFinalLineBreaks(source []byte, lineBreak []byte) int

func DetectLineBreak added in v1.2.3

func DetectLineBreak(source []byte) []byte

func ParseFrontmatter added in v1.2.1

func ParseFrontmatter(raw string) (f Frontmatter, info FrontmatterParseInfo)

Types

type Attributes added in v1.3.0

type Attributes map[string]string

type Block

type Block interface {
	Kind() BlockKind
	Unwrap() ast.Node
	Value() []byte
}

type BlockKind added in v0.4.0

type BlockKind int
const (
	InnerBlockKind BlockKind = iota + 1
	CodeBlockKind
	MarkdownBlockKind
)

type Blocks

type Blocks []Block

type CodeBlock

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

func (*CodeBlock) Attributes

func (b *CodeBlock) Attributes() map[string]string

func (*CodeBlock) Background added in v1.0.1

func (b *CodeBlock) Background() bool

func (*CodeBlock) Category added in v1.2.0

func (b *CodeBlock) Category() string

func (*CodeBlock) Clone added in v1.2.1

func (b *CodeBlock) Clone() *CodeBlock

func (*CodeBlock) Content

func (b *CodeBlock) Content() []byte

func (*CodeBlock) Cwd added in v1.2.1

func (b *CodeBlock) Cwd() string

func (*CodeBlock) ExcludeFromRunAll added in v1.2.0

func (b *CodeBlock) ExcludeFromRunAll() bool

func (*CodeBlock) GetBlock added in v1.2.0

func (b *CodeBlock) GetBlock() *CodeBlock

func (*CodeBlock) GetFile added in v1.2.0

func (b *CodeBlock) GetFile() string

func (*CodeBlock) GetFileRel added in v1.2.1

func (b *CodeBlock) GetFileRel() string

func (*CodeBlock) GetFrontmatter added in v1.2.1

func (b *CodeBlock) GetFrontmatter() Frontmatter

func (*CodeBlock) Interactive added in v0.6.2

func (b *CodeBlock) Interactive() bool

func (*CodeBlock) Interpreter added in v1.6.0

func (b *CodeBlock) Interpreter() string

func (*CodeBlock) Intro

func (b *CodeBlock) Intro() string

func (*CodeBlock) IsUnknown added in v1.6.0

func (b *CodeBlock) IsUnknown() bool

func (*CodeBlock) IsUnnamed added in v1.6.0

func (b *CodeBlock) IsUnnamed() bool

func (CodeBlock) Kind added in v0.4.0

func (CodeBlock) Kind() BlockKind

func (*CodeBlock) Language added in v0.4.0

func (b *CodeBlock) Language() string

func (*CodeBlock) Lines

func (b *CodeBlock) Lines() []string

func (*CodeBlock) Name

func (b *CodeBlock) Name() string

func (*CodeBlock) PromptEnv added in v1.2.1

func (b *CodeBlock) PromptEnv() bool

func (*CodeBlock) SetLine added in v1.2.1

func (b *CodeBlock) SetLine(p int, v string)

func (*CodeBlock) TextRange added in v1.0.2

func (b *CodeBlock) TextRange() (textRange TextRange)

func (*CodeBlock) Unwrap added in v0.4.0

func (b *CodeBlock) Unwrap() ast.Node

func (*CodeBlock) Value added in v0.4.0

func (b *CodeBlock) Value() []byte

type CodeBlocks

type CodeBlocks []*CodeBlock

func CollectCodeBlocks added in v0.4.0

func CollectCodeBlocks(node *Node) (result CodeBlocks)

func (CodeBlocks) Lookup

func (b CodeBlocks) Lookup(name string) *CodeBlock

func (CodeBlocks) Names

func (b CodeBlocks) Names() (result []string)

type Document added in v0.4.0

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

func New added in v0.4.0

func New(source []byte, renderer Renderer) *Document

func (*Document) Parse added in v0.4.0

func (d *Document) Parse() (*Node, ast.Node, error)

type Frontmatter added in v1.2.1

type Frontmatter struct {
	Shell string
	Cwd   string
}

func (Frontmatter) ToParser added in v1.2.1

func (fmtr Frontmatter) ToParser() *parserv1.Frontmatter

type FrontmatterParseInfo added in v1.2.1

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

func (FrontmatterParseInfo) Error added in v1.2.1

func (fpi FrontmatterParseInfo) Error() error

func (FrontmatterParseInfo) JSONError added in v1.2.1

func (fpi FrontmatterParseInfo) JSONError() error

func (FrontmatterParseInfo) TOMLError added in v1.2.1

func (fpi FrontmatterParseInfo) TOMLError() error

func (FrontmatterParseInfo) YAMLError added in v1.2.1

func (fpi FrontmatterParseInfo) YAMLError() error

type InnerBlock added in v0.4.0

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

InnerBlock represents a non-leaf block. It helps to handle nested fenced code blocks for block quotes and list items.

func (InnerBlock) Kind added in v0.4.0

func (InnerBlock) Kind() BlockKind

func (*InnerBlock) Unwrap added in v0.4.0

func (b *InnerBlock) Unwrap() ast.Node

func (*InnerBlock) Value added in v0.4.0

func (b *InnerBlock) Value() []byte

type MarkdownBlock

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

func (MarkdownBlock) Kind added in v0.4.0

func (MarkdownBlock) Kind() BlockKind

func (*MarkdownBlock) Unwrap added in v0.4.0

func (b *MarkdownBlock) Unwrap() ast.Node

func (*MarkdownBlock) Value added in v0.4.0

func (b *MarkdownBlock) Value() []byte

type Node added in v0.4.0

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

func FindNode added in v0.4.0

func FindNode(node *Node, fn func(*Node) bool) *Node

func (*Node) Bytes added in v0.4.0

func (n *Node) Bytes() []byte

func (*Node) Children added in v0.4.0

func (n *Node) Children() []*Node

func (*Node) Index added in v0.4.0

func (n *Node) Index() int

func (*Node) InsertAt added in v0.4.0

func (n *Node) InsertAt(idx int, item Block) *Node

func (*Node) Item added in v0.4.0

func (n *Node) Item() Block

func (*Node) Parent added in v0.4.0

func (n *Node) Parent() *Node

func (*Node) Remove added in v0.4.0

func (n *Node) Remove(nodeToRemove *Node) bool

func (*Node) String added in v0.4.0

func (n *Node) String() string

type ParsedSections added in v0.4.1

type ParsedSections struct {
	FrontMatter   []byte
	Content       []byte
	ContentOffset int
}

func ParseSections added in v0.4.1

func ParseSections(source []byte) (result ParsedSections, _ error)

type Renderer added in v0.4.0

type Renderer func(ast.Node, []byte) ([]byte, error)

type TextRange added in v1.0.2

type TextRange struct {
	Start int
	End   int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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