parser

package
v0.0.0-...-403fe75 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockNodes

func BlockNodes(nodesToEncapsulate []nodes.Node) []nodes.Node

nodeBlocks encapsulates all nodes of the same block into a new ListNode with its B field set to true. Nodes which are not blockSquashable remain as is.

func CompactNodes

func CompactNodes(nodesToCompact []nodes.Node) []nodes.Node

Although the input slice is not modified, its elements are.

func Parse

func Parse(name string, r io.Reader, opts Options) (*types.Codelab, error)

Parse parses source r into a Codelab using a parser registered with the specified name.

func ParseFragment

func ParseFragment(name string, r io.Reader, opts Options) ([]nodes.Node, error)

ParseFragment parses a codelab fragment provided in r, using a parser registered with the specified name.

func Parsers

func Parsers() []string

Parsers returns a slice of all registered parser names.

func Register

func Register(name string, p Parser)

Register registers a new parser f under specified name. It panics if another parser is already registered under the same name.

Types

type Options

type Options struct {
	PassMetadata map[string]bool
}

Container for parsing options.

func NewOptions

func NewOptions() *Options

type Parser

type Parser interface {
	// Parse parses source r into a Codelab for the specified environment env.
	Parse(r io.Reader, opts Options) (*types.Codelab, error)

	// ParseFragment is similar to Parse except it doesn't parse codelab metadata.
	ParseFragment(r io.Reader, opts Options) ([]nodes.Node, error)
}

Parser parses a codelab in specific resource format. Each parser needs to call Register to become a known parser.

Directories

Path Synopsis
Package md implements a parser for CLaaT. It expects, as input, the output of running a Markdown file through the Markdown processor.
Package md implements a parser for CLaaT. It expects, as input, the output of running a Markdown file through the Markdown processor.

Jump to

Keyboard shortcuts

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