pandoc-1.11.1: Conversion between markup formats

Portability | portable
Stability | alpha
Maintainer | John MacFarlane <jgm@berkeley.edu>
Safe Haskell | None

Text.Pandoc.Pretty

Description

A prettyprinting library for the production of text documents, including wrapped text, indentated blocks, and tables.

Synopsis

- data Doc
- render :: (Monoid a, IsString a) => Maybe Int -> Doc -> a
- cr :: Doc
- blankline :: Doc
- space :: Doc
- text :: String -> Doc
- char :: Char -> Doc
- prefixed :: String -> Doc -> Doc
- flush :: Doc -> Doc
- nest :: Int -> Doc -> Doc
- hang :: Int -> Doc -> Doc -> Doc
- beforeNonBlank :: Doc -> Doc
- nowrap :: Doc -> Doc
- offset :: Doc -> Int
- height :: Doc -> Int
- lblock :: Int -> Doc -> Doc
- cblock :: Int -> Doc -> Doc
- rblock :: Int -> Doc -> Doc
- (<>) :: Monoid m => m -> m -> m
- (<+>) :: Doc -> Doc -> Doc
- ($$) :: Doc -> Doc -> Doc
- ($+$) :: Doc -> Doc -> Doc
- isEmpty :: Doc -> Bool
- empty :: Doc
- cat :: [Doc] -> Doc
- hcat :: [Doc] -> Doc
- hsep :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- chomp :: Doc -> Doc
- inside :: Doc -> Doc -> Doc -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- parens :: Doc -> Doc
- quotes :: Doc -> Doc
- doubleQuotes :: Doc -> Doc
- charWidth :: Char -> Int
- realLength :: String -> Int

# Documentation

data Doc

Instances

Show Doc |
IsString Doc |
Monoid Doc |

render :: (Monoid a, IsString a) => Maybe Int -> Doc -> a

Renders a `Doc`. `render (Just n)` will use a line length of `n` to reflow text on breakable spaces. `render Nothing` will not reflow text.

cr :: Doc

A carriage return. Does nothing if we're at the beginning of a line; otherwise inserts a newline.

blankline :: Doc

Inserts a blank line unless one exists already. (`blankline blankline` has the same effect as `blankline`. If you want multiple blank lines, use `text \n\n`.

space :: Doc

A breaking (reflowable) space.

text :: String -> Doc

A literal string.

char :: Char -> Doc

A character.

prefixed :: String -> Doc -> Doc

Uses the specified string as a prefix for every line of the inside document (except the first, if not at the beginning of the line).

flush :: Doc -> Doc

Makes a `Doc` flush against the left margin.

nest :: Int -> Doc -> Doc

Indents a `Doc` by the specified number of spaces.

hang :: Int -> Doc -> Doc -> Doc

A hanging indent. `hang ind start doc` prints `start`, then `doc`, leaving an indent of `ind` spaces on every line but the first.

beforeNonBlank :: Doc -> Doc

`beforeNonBlank d` conditionally includes `d` unless it is followed by blank space.

nowrap :: Doc -> Doc

Makes a `Doc` non-reflowable.

offset :: Doc -> Int

Returns the width of a `Doc`.

height :: Doc -> Int

Returns the height of a block or other `Doc`.

lblock :: Int -> Doc -> Doc

`lblock n d` is a block of width `n` characters, with text derived from `d` and aligned to the left.

cblock :: Int -> Doc -> Doc

Like `lblock` but aligned centered.

rblock :: Int -> Doc -> Doc

Like `lblock` but aligned to the right.

(<>) :: Monoid m => m -> m -> m

An infix synonym for `mappend`.

(<+>) :: Doc -> Doc -> Doc

Concatenate a list of `Doc`s, putting breakable spaces between them.

($$) :: Doc -> Doc -> Doc

`a $$ b` puts `a` above `b`.

($+$) :: Doc -> Doc -> Doc

`a $$ b` puts `a` above `b`, with a blank line between.

isEmpty :: Doc -> Bool

True if the document is empty.

empty :: Doc

The empty document.

cat :: [Doc] -> Doc

Concatenate a list of `Doc`s.

hcat :: [Doc] -> Doc

Same as `cat`.

hsep :: [Doc] -> Doc

Same as `cat`, but putting breakable spaces between the `Doc`s.

vcat :: [Doc] -> Doc

List version of `$$`.

vsep :: [Doc] -> Doc

List version of `$+$`.

chomp :: Doc -> Doc

Chomps trailing blank space off of a `Doc`.

inside :: Doc -> Doc -> Doc -> Doc

Encloses a `Doc` inside a start and end `Doc`.

braces :: Doc -> Doc

Puts a `Doc` in curly braces.

brackets :: Doc -> Doc

Puts a `Doc` in square brackets.

parens :: Doc -> Doc

Puts a `Doc` in parentheses.

quotes :: Doc -> Doc

Wraps a `Doc` in single quotes.

doubleQuotes :: Doc -> Doc

Wraps a `Doc` in double quotes.

charWidth :: Char -> Int

Returns width of a character in a monospace font: 0 for a combining character, 1 for a regular character, 2 for an East Asian wide character.

realLength :: String -> Int

Get real length of string, taking into account combining and double-wide characters.