options.go 1.1 KB

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