parser

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: EUPL-1.2 Imports: 10 Imported by: 0

Documentation

Overview

Package parser provides a generic interface to a range of different parsers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSyntaxes added in v0.0.15

func GetSyntaxes() []string

GetSyntaxes returns a list of syntaxes implemented by all registered parsers.

func IsASTParser added in v0.9.0

func IsASTParser(syntax string) bool

IsASTParser returns whether the given syntax parses text into an AST or not.

func IsImageFormat added in v0.0.15

func IsImageFormat(syntax string) bool

IsImageFormat returns whether the given syntax is known to be an image format.

func NormalizedSpacedText added in v0.11.0

func NormalizedSpacedText(s string) string

NormalizedSpacedText returns the given string, but normalize multiple spaces to one space.

func ParseBlocks added in v0.0.15

func ParseBlocks(inp *input.Input, m *meta.Meta, syntax string, hi config.HTMLInsecurity) ast.BlockSlice

ParseBlocks parses some input and returns a slice of block nodes.

func ParseDescription added in v0.10.0

func ParseDescription(m *meta.Meta) ast.InlineSlice

ParseDescription returns a suitable description stored in the metadata as an inline slice. This is done for an image in most cases.

func ParseInlines added in v0.0.15

func ParseInlines(inp *input.Input, syntax string) ast.InlineSlice

ParseInlines parses some input and returns a slice of inline nodes.

func ParseMetadata added in v0.0.15

func ParseMetadata(value string) ast.InlineSlice

ParseMetadata parses a string as Zettelmarkup, resulting in an inline slice. Typically used to parse the title or other metadata of type Zettelmarkup.

func ParseSpacedText added in v0.11.0

func ParseSpacedText(s string) ast.InlineSlice

ParseSpacedText returns an inline slice that consists just of test and space node. No Zettelmarkup parsing is done. It is typically used to transform the zettel title into an inline slice.

func ParseZettel added in v0.0.15

func ParseZettel(ctx context.Context, zettel zettel.Zettel, syntax string, rtConfig config.Config) *ast.ZettelNode

ParseZettel parses the zettel based on the syntax.

func Register

func Register(pi *Info)

Register the parser (info) for later retrieval.

Types

type Info

type Info struct {
	Name          string
	AltNames      []string
	IsASTParser   bool
	IsTextFormat  bool
	IsImageFormat bool
	ParseBlocks   func(*input.Input, *meta.Meta, string) ast.BlockSlice
	ParseInlines  func(*input.Input, string) ast.InlineSlice
}

Info describes a single parser.

Before ParseBlocks() or ParseInlines() is called, ensure the input stream to be valid. This can ce achieved on calling inp.Next() after the input stream was created.

func Get

func Get(name string) *Info

Get the parser (info) by name. If name not found, use a default parser.

Directories

Path Synopsis
Package blob provides a parser of binary data.
Package blob provides a parser of binary data.
Package cleaner provides functions to clean up the parsed AST.
Package cleaner provides functions to clean up the parsed AST.
Package draw provides a parser to create SVG from ASCII drawing.
Package draw provides a parser to create SVG from ASCII drawing.
Package markdown provides a parser for markdown.
Package markdown provides a parser for markdown.
Package none provides a none-parser, e.g.
Package none provides a none-parser, e.g.
Package plain provides a parser for plain text data.
Package plain provides a parser for plain text data.
Package zettelmark provides a parser for zettelmarkup.
Package zettelmark provides a parser for zettelmarkup.

Jump to

Keyboard shortcuts

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