slab-0.0.2.0: A programmable markup language to generate HTML
Safe HaskellSafe-Inferred
LanguageHaskell2010

Slab.Parse

Description

Slab.Parse provides parsers to read text and construct an abstract syntax tree, as represented by Slab.Syntax.

Parsers are written using the megaparsec library.

Synopsis

Documentation

parseExpr :: Text -> Either (ParseErrorBundle Text Void) Expr Source #

We expose the expression parser for development:

    Parse.parseExpr "1 + 2 * a"

parserTextInclude :: Text -> Block Source #

A parser to convert the content of an included to Syntax. The behavior w.r.t. to newlines should be the same as having each line directly preceded by a | in the including file.

The InterpolationContext type

type InterpolationContext f = Text -> f Text Source #

A mapping from placeholders in the template to values with an applicative lookup function. For instance the lookup function can fail, returning Nothing or Left.

Basic interface

parse' :: Text -> Either (ParseErrorBundle Text Void) [Inline] Source #

Create a template from a template string. A malformed template string will cause parse to return a parse error.