Documentation
¶
Index ¶
- func IsAsciidoc(path string) bool
- func Parse(filename string, b []byte, opts ...Option) (interface{}, error)
- func ParseDocument(r io.Reader, config configuration.Configuration) (types.Document, error)
- func ParseDraftDocument(r io.Reader, config configuration.Configuration, options ...Option) (types.DraftDocument, error)
- func ParseFile(filename string, opts ...Option) (i interface{}, err error)
- func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error)
- type ContextKey
- type Option
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAsciidoc ¶ added in v0.3.0
IsAsciidoc returns true if the file to include is an asciidoc file (based on the file location extension)
func ParseDocument ¶ added in v0.3.0
func ParseDocument(r io.Reader, config configuration.Configuration) (types.Document, error)
ParseDocument parses the content of the reader identitied by the filename
func ParseDraftDocument ¶ added in v0.3.0
func ParseDraftDocument(r io.Reader, config configuration.Configuration, options ...Option) (types.DraftDocument, error)
ParseDraftDocument parses a document's content and applies the preprocessing directives (file inclusions)
Types ¶
type ContextKey ¶ added in v0.3.0
type ContextKey string
ContextKey a non-built-in type for keys in the context
const LevelOffset ContextKey = "leveloffset"
LevelOffset the key for the level offset of the file to include
type Option ¶
type Option func(*parser) Option
Option is a function that can set an option on the parser. It returns the previous setting as an Option.
func AllowInvalidUTF8 ¶
AllowInvalidUTF8 creates an Option to allow invalid UTF-8 bytes. Every invalid UTF-8 byte is treated as a utf8.RuneError (U+FFFD) by character class matchers and is matched by the any matcher. The returned matched value, c.text and c.offset are NOT affected.
The default is false.
func Entrypoint ¶
Entrypoint creates an Option to set the rule name to use as entrypoint. The rule name must have been specified in the -alternate-entrypoints if generating the parser with the -optimize-grammar flag, otherwise it may have been optimized out. Passing an empty string sets the entrypoint to the first rule in the grammar.
The default is to start parsing at the first rule in the grammar.
func GlobalStore ¶
GlobalStore creates an Option to set a key to a certain value in the globalStore.
func MaxExpressions ¶
MaxExpressions creates an Option to stop parsing after the provided number of expressions have been parsed, if the value is 0 then the parser will parse for as many steps as needed (possibly an infinite number).
The default for maxExprCnt is 0.
type Stats ¶
type Stats struct { // ExprCnt counts the number of expressions processed during parsing // This value is compared to the maximum number of expressions allowed // (set by the MaxExpressions option). ExprCnt uint64 // ChoiceAltCnt is used to count for each ordered choice expression, // which alternative is used how may times. // These numbers allow to optimize the order of the ordered choice expression // to increase the performance of the parser // // The outer key of ChoiceAltCnt is composed of the name of the rule as well // as the line and the column of the ordered choice. // The inner key of ChoiceAltCnt is the number (one-based) of the matching alternative. // For each alternative the number of matches are counted. If an ordered choice does not // match, a special counter is incremented. The name of this counter is set with // the parser option Statistics. // For an alternative to be included in ChoiceAltCnt, it has to match at least once. ChoiceAltCnt map[string]map[string]int }
Stats stores some statistics, gathered during parsing
Source Files
¶
- document_preprocessing.go
- document_processing.go
- document_processing_apply_substitutions.go
- document_processing_filter_blocks.go
- document_processing_footnotes.go
- document_processing_include_toc_placeholder.go
- document_processing_insert_preamble.go
- document_processing_rearrange_lists.go
- document_processing_rearrange_sections.go
- file_inclusion.go
- parser.go