flexible-unlit-0.2013.314.0: A configurable reimplementation of unlit

Portabilityportable
Stabilityexperimental
Maintainerrhymoid@gmail.com
Safe HaskellNone

Language.Preprocessor.Unlit

Contents

Description

 

Synopsis

unlit

unlit :: Text -> ([UnlitError], Text)Source

Runs unlitWith, using the default parsers of GHC.

unlitWith :: [Parser Text] -> Text -> ([UnlitError], Text)Source

Runs unlitLinesWith, with the provided Text split into lines

unlitLinesWith :: [Parser Text] -> [Text] -> ([UnlitError], [Text])Source

Parse a list of lines, given a sequence of parsers.

Parsers

ghcParsers :: [Parser Text]Source

The default parsers used by GHC (latexParser, birdParser, and cppParser).

latexParser :: Parser TextSource

Parser for blocks of code delimited by \begin{code} and \end{code} or \begin{pseudocode} and \end{pseudocode}.

birdParser :: Parser TextSource

Parser for blocks of code prefixed by > or <.

cppParser :: Parser TextSource

Parser for lines prefixed by #.

pandocMarkdownParser :: (Text -> Active) -> Parser TextSource

Parser for lines fenced by backticks or tildes.

Defining custom parsers

newtype Parser x Source

Constructors

Parser (x -> [x] -> Maybe ([Classified x], Maybe [x])) 

data Classified x Source

Constructors

Program NeedHug Active x

Program lines.

Comment

Comment lines.

Blank

Blank lines.

data NeedHug Source

Constructors

NeedHug

A sequence of program lines needs blank lines around it.

Whatever

This line doesn't care about adjacent lines.

data Active Source

Constructors

Active

An active line of code.

Inactive

An inactive line of code.

Splitting and joining lines

lines :: Text -> [Text]Source

Breaks a Text up into a list of Texts at newline sequences. The resulting strings do not contain newline sequences.

This function accepts '\r\n', '\r' and '\n' as newline sequences.

unlines :: [Text] -> TextSource

Joins lines of Text. In the resulting string, lines are terminated with a single newline character ('\n').