Documentation ¶
Index ¶
- Constants
- func Aggregate(ctx *ParseContext, fragmentStream <-chan types.DocumentFragment) (*types.Document, error)
- func ApplySubstitutions(ctx *ParseContext, done <-chan interface{}, ...) chan types.DocumentFragment
- func ArrangeLists(done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) <-chan types.DocumentFragment
- func CollectFootnotes(n *types.Footnotes, done <-chan interface{}, ...) chan types.DocumentFragment
- func FilterOut(done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) <-chan types.DocumentFragment
- func IsAsciidoc(path string) bool
- func Parse(filename string, b []byte, opts ...Option) (interface{}, error)
- func ParseDocument(r io.Reader, config *configuration.Configuration, opts ...Option) (*types.Document, error)
- func ParseDocumentFragments(ctx *ParseContext, source io.Reader, done <-chan interface{}) <-chan types.DocumentFragment
- func ParseFile(filename string, opts ...Option) (i interface{}, err error)
- func ParseReader(filename string, r io.Reader, opts ...Option) (interface{}, error)
- func Preprocess(source io.Reader, config *configuration.Configuration, opts ...Option) (string, error)
- func PrettyPrintStats(stats *Stats) string
- func RefineFragments(ctx *ParseContext, source io.Reader, done <-chan interface{}, ...) chan types.DocumentFragment
- type Cloner
- type Option
- type ParseContext
- type Stats
Constants ¶
const ( // AttributeRefs the "attribute_refs" substitution AttributeRefs string = "attributes" // TODO: no need to export // Callouts the "callouts" substitution Callouts string = "callouts" // InlinePassthroughs the "inline_passthrough" substitution InlinePassthroughs string = "inline_passthrough" //nolint:gosec // Macros the "macros" substitution Macros string = "macros" // None the "none" substitution None string = "none" // PostReplacements the "post_replacements" substitution PostReplacements string = "post_replacements" // Quotes the "quotes" substitution Quotes string = "quotes" // Replacements the "replacements" substitution Replacements string = "replacements" // SpecialCharacters the "specialchars" substitution SpecialCharacters string = "specialchars" )
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶ added in v0.7.0
func Aggregate(ctx *ParseContext, fragmentStream <-chan types.DocumentFragment) (*types.Document, error)
Aggregate pipeline task which organizes the sections in hierarchy, and keeps track of their references. Also, takes care of wrapping all blocks between header (section 0) and first child section into a `Preamble` Also, takes care of inserting the Table of Contents returns the whole document at once (or an error)
func ApplySubstitutions ¶ added in v0.5.0
func ApplySubstitutions(ctx *ParseContext, done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) chan types.DocumentFragment
ApplySubstitutions parses the "inline content" of the incomgin fragment elements (eg, paragraph content to convert rawlines into slices of StringElement, QuotedText, InlineLinks, etc.), while also applying the required substitutions (default or custom)
func ArrangeLists ¶ added in v0.7.0
func ArrangeLists(done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) <-chan types.DocumentFragment
ArrangeLists pipeline task which consists join list elements into lists
func CollectFootnotes ¶ added in v0.7.0
func CollectFootnotes(n *types.Footnotes, done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) chan types.DocumentFragment
func FilterOut ¶ added in v0.7.0
func FilterOut(done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) <-chan types.DocumentFragment
Filter removes all blocks that should not appear in the final document: - blank lines (except in delimited blocks) - empty preambles - single line comments and comment blocks
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, opts ...Option) (*types.Document, error)
ParseDocument parses the content of the reader identitied by the filename and applies all the substitutions and arrangements
func ParseDocumentFragments ¶ added in v0.8.0
func ParseDocumentFragments(ctx *ParseContext, source io.Reader, done <-chan interface{}) <-chan types.DocumentFragment
func ParseReader ¶
ParseReader parses the data from r using filename as information in the error messages.
func Preprocess ¶ added in v0.7.0
func Preprocess(source io.Reader, config *configuration.Configuration, opts ...Option) (string, error)
Preprocess reads line by line to look-up and process file inclusions and conditionals (`ifdef`, `ifndef` and `ifeval`)
func PrettyPrintStats ¶ added in v0.7.0
func RefineFragments ¶ added in v0.8.0
func RefineFragments(ctx *ParseContext, source io.Reader, done <-chan interface{}, fragmentStream <-chan types.DocumentFragment) chan types.DocumentFragment
Parses the content of the conplex elements in the incoming fragments (for example, some delimited blocks may contain paragraphs, etc.)
Types ¶
type Cloner ¶
type Cloner interface {
Clone() interface{}
}
Cloner is implemented by any value that has a Clone method, which returns a copy of the value. This is mainly used for types which are not passed by value (e.g map, slice, chan) or structs that contain such types.
This is used in conjunction with the global state feature to create proper copies of the state to allow the parser to properly restore the state in the case of backtracking.
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 InitState ¶
InitState creates an Option to set a key to a certain value in the global "state" store.
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 ParseContext ¶ added in v0.7.0
type ParseContext struct {
// contains filtered or unexported fields
}
func NewParseContext ¶ added in v0.7.0
func NewParseContext(config *configuration.Configuration, options ...Option) *ParseContext
func (*ParseContext) Clone ¶ added in v0.7.0
func (c *ParseContext) Clone() *ParseContext
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 ¶
- context.go
- document_preprocessing.go
- document_processing.go
- document_processing_aggregate.go
- document_processing_apply_substitutions.go
- document_processing_arrange_lists.go
- document_processing_collect_footnotes.go
- document_processing_filter_elements.go
- document_processing_parse_fragments.go
- document_processing_refine_fragments.go
- document_substitutions.go
- generate.go
- parser.go
- parser_ext.go
- stats.go