parser

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: EUPL-1.2 Imports: 22 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var SymAllowHTML = sx.MakeSymbol("ALLOW-HTML")

SymAllowHTML signals a parser to allow HTML content during parsing.

Functions

func Clean

func Clean(node *sx.Pair)

Clean the given SZ syntax tree.

func GetSyntaxes

func GetSyntaxes() []string

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

func IsASTParser

func IsASTParser(syntax string) bool

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

func IsImageFormat

func IsImageFormat(syntax string) bool

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

func Parse

func Parse(inp *input.Input, m *meta.Meta, syntax string, alst *sx.Pair) *sx.Pair

Parse parses some input and returns both a Sx.Object and a slice of block nodes.

func ParseDescription

func ParseDescription(m *meta.Meta) *sx.Pair

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

func ParseDrawBlock

func ParseDrawBlock(attrs *sx.Pair, content []byte) *sx.Pair

ParseDrawBlock parses the content of an eval verbatim node into an SVG image BLOB.

func ParseZettel

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

ParseZettel parses the zettel based on the syntax.

Types

type Info

type Info struct {
	Name          string
	AltNames      []string
	IsASTParser   bool
	IsTextFormat  bool
	IsImageFormat bool

	// Parse the input, with the given metadata, the given syntax, and the given config.
	Parse func(*input.Input, *meta.Meta, string, *sx.Pair) *sx.Pair
}

Info describes a single parser.

Before Parse() is called, ensure the input stream to be valid. This can be 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.

Jump to

Keyboard shortcuts

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