options.go

 1package parser
 2
 3import (
 4	"github.com/gomarkdown/markdown/ast"
 5)
 6
 7// Flags control optional behavior of parser.
 8type Flags int
 9
10// Options is a collection of supplementary parameters tweaking the behavior of various parts of the parser.
11type Options struct {
12	ParserHook    BlockFunc
13	ReadIncludeFn ReadIncludeFunc
14
15	Flags Flags // Flags allow customizing parser's behavior
16}
17
18// Parser renderer configuration options.
19const (
20	FlagsNone        Flags = 0
21	SkipFootnoteList Flags = 1 << iota // Skip adding the footnote list (regardless if they are parsed)
22)
23
24// BlockFunc allows to registration of a parser function. If successful it
25// returns an ast.Node, a buffer that should be parsed as a block and the the number of bytes consumed.
26type BlockFunc func(data []byte) (ast.Node, []byte, int)
27
28// ReadIncludeFunc should read the file under path and returns the read bytes,
29// from will be set to the name of the current file being parsed. Initially
30// this will be empty. address is the optional address specifier of which lines
31// of the file to return. If this function is not set no data will be read.
32type ReadIncludeFunc func(from, path string, address []byte) []byte