pandoc-1.10.1: Conversion between markup formats

Portabilityportable
Stabilityalpha
MaintainerJohn MacFarlane <jgm@berkeley.edu>
Safe HaskellNone

Text.Pandoc.Parsing

Contents

Description

A utility library with parsers used in pandoc readers.

Synopsis

Documentation

(>>~) :: Monad m => m a -> m b -> m aSource

Like >>, but returns the operation on the left. (Suggested by Tillmann Rendel on Haskell-cafe list.)

anyLine :: Parser [Char] st [Char]Source

Parse any line of text

many1Till :: Parser [tok] st a -> Parser [tok] st end -> Parser [tok] st [a]Source

Like manyTill, but reads at least one item.

notFollowedBy' :: Show b => Parser [a] st b -> Parser [a] st ()Source

A more general form of notFollowedBy. This one allows any type of parser to be specified, and succeeds only if that parser fails. It does not consume any input.

oneOfStrings :: [String] -> Parser [Char] st StringSource

Parses one of a list of strings. If the list contains two strings one of which is a prefix of the other, the longer string will be matched if possible.

oneOfStringsCI :: [String] -> Parser [Char] st StringSource

Parses one of a list of strings (tried in order), case insensitive.

spaceChar :: Parser [Char] st CharSource

Parses a space or tab.

nonspaceChar :: Parser [Char] st CharSource

Parses a nonspace, nonnewline character.

skipSpaces :: Parser [Char] st ()Source

Skips zero or more spaces or tabs.

blankline :: Parser [Char] st CharSource

Skips zero or more spaces or tabs, then reads a newline.

blanklines :: Parser [Char] st [Char]Source

Parses one or more blank lines and returns a string of newlines.

enclosedSource

Arguments

:: Parser [Char] st t

start parser

-> Parser [Char] st end

end parser

-> Parser [Char] st a

content parser (to be used repeatedly)

-> Parser [Char] st [a] 

Parses material enclosed between start and end parsers.

stringAnyCase :: [Char] -> Parser [Char] st StringSource

Parse string, case insensitive.

parseFromString :: Parser [tok] st a -> [tok] -> Parser [tok] st aSource

Parse contents of str using parser and return result.

lineClump :: Parser [Char] st StringSource

Parse raw line block up to and including blank lines.

charsInBalanced :: Char -> Char -> Parser [Char] st Char -> Parser [Char] st StringSource

Parse a string of characters between an open character and a close character, including text between balanced pairs of open and close, which must be different. For example, charsInBalanced '(' ')' anyChar will parse (hello (there)) and return hello (there).

romanNumeralSource

Arguments

:: Bool

Uppercase if true

-> Parser [Char] st Int 

Parses a roman numeral (uppercase or lowercase), returns number.

emailAddress :: Parser [Char] st (String, String)Source

Parses an email address; returns original and corresponding escaped mailto: URI.

uri :: Parser [Char] st (String, String)Source

Parses a URI. Returns pair of original and URI-escaped version.

withHorizDisplacementSource

Arguments

:: Parser [Char] st a

Parser to apply

-> Parser [Char] st (a, Int)

(result, displacement)

Applies a parser, returns tuple of its results and its horizontal displacement (the difference between the source column at the end and the source column at the beginning). Vertical displacement (source row) is ignored.

withRaw :: Parser [Char] st a -> Parser [Char] st (a, [Char])Source

Applies a parser and returns the raw string that was parsed, along with the value produced by the parser.

escapedSource

Arguments

:: Parser [Char] st Char

Parser for character to escape

-> Parser [Char] st Char 

Parses backslash, then applies character parser.

characterReference :: Parser [Char] st CharSource

Parse character entity.

anyOrderedListMarker :: Parser [Char] ParserState ListAttributesSource

Parses an ordered list marker and returns list attributes.

orderedListMarker :: ListNumberStyle -> ListNumberDelim -> Parser [Char] ParserState IntSource

Parses an ordered list marker with a given style and delimiter, returns number.

charRef :: Parser [Char] st InlineSource

Parses a character reference and returns a Str element.

lineBlockLines :: Parser [Char] st [String]Source

Parses an RST-style line block and returns a list of strings.

tableWith :: Parser [Char] ParserState ([[Block]], [Alignment], [Int]) -> ([Int] -> Parser [Char] ParserState [[Block]]) -> Parser [Char] ParserState sep -> Parser [Char] ParserState end -> Parser [Char] ParserState BlockSource

Parse a table using headerParser, rowParser, lineParser, and footerParser.

gridTableWithSource

Arguments

:: Parser [Char] ParserState [Block]

Block list parser

-> Bool

Headerless table

-> Parser [Char] ParserState Block 

readWithSource

Arguments

:: Parser [t] ParserState a

parser

-> ParserState

initial state

-> [t]

input

-> a 

Parse a string with a given parser and state.

testStringWith :: Show a => Parser [Char] ParserState a -> String -> IO ()Source

Parse a string with parser (for testing).

guardEnabled :: Extension -> Parser s ParserState ()Source

Succeed only if the extension is enabled.

guardDisabled :: Extension -> Parser s ParserState ()Source

Succeed only if the extension is disabled.

data ParserState Source

Parsing options.

Constructors

ParserState 

Fields

stateOptions :: ReaderOptions

User options

stateParserContext :: ParserContext

Inside list?

stateQuoteContext :: QuoteContext

Inside quoted environment?

stateAllowLinks :: Bool

Allow parsing of links

stateMaxNestingLevel :: Int

Max # of nested Strong/Emph

stateLastStrPos :: Maybe SourcePos

Position after last str parsed

stateKeys :: KeyTable

List of reference keys (with fallbacks)

stateSubstitutions :: SubstTable

List of substitution references

stateNotes :: NoteTable

List of notes (raw bodies)

stateNotes' :: NoteTable'

List of notes (parsed bodies)

stateTitle :: [Inline]

Title of document

stateAuthors :: [[Inline]]

Authors of document

stateDate :: [Inline]

Date of document

stateHeaderTable :: [HeaderType]

Ordered list of header types used

stateHeaders :: [[Inline]]

List of headers (used for implicit ref links)

stateIdentifiers :: [String]

List of header identifiers used

stateNextExample :: Int

Number of next example

stateExamples :: Map String Int

Map from example labels to numbers

stateHasChapters :: Bool

True if chapter encountered

stateMacros :: [Macro]

List of macros defined so far

stateRstDefaultRole :: String

Current rST default interpreted text role

stateWarnings :: [String]

Warnings generated by the parser

Instances

data HeaderType Source

Constructors

SingleHeader Char

Single line of characters underneath

DoubleHeader Char

Lines of characters above and below

data ParserContext Source

Constructors

ListItemState

Used when running parser on list item contents

NullState

Default state

data QuoteContext Source

Constructors

InSingleQuote

Used when parsing inside single quotes

InDoubleQuote

Used when parsing inside double quotes

NoQuote

Used when not parsing inside quotes

newtype Key Source

Constructors

Key String 

Instances

macro :: Parser [Char] ParserState BlocksSource

Parse a newcommand or renewcommand macro definition.

applyMacros' :: String -> Parser [Char] ParserState StringSource

Apply current macros to string.

type Parser t s = Parsec t sSource

newtype F a Source

Constructors

F 

Fields

unF :: Reader ParserState a
 

Instances

Monad F 
Functor F 
Monoid a => Monoid (F a) 

runF :: F a -> ParserState -> aSource

asksF :: (ParserState -> a) -> F aSource

Re-exports from Text.Pandoc.Parsec

runParser :: Stream s Identity t => Parsec s u a -> u -> SourceName -> s -> Either ParseError a

parse :: Stream s Identity t => Parsec s () a -> SourceName -> s -> Either ParseError a

anyToken :: (Stream s m t, Show t) => ParsecT s u m t

getInput :: Monad m => ParsecT s u m s

setInput :: Monad m => s -> ParsecT s u m ()

unexpected :: Stream s m t => String -> ParsecT s u m a

char :: Stream s m Char => Char -> ParsecT s u m Char

letter :: Stream s m Char => ParsecT s u m Char

digit :: Stream s m Char => ParsecT s u m Char

alphaNum :: Stream s m Char => ParsecT s u m Char

skipMany :: ParsecT s u m a -> ParsecT s u m ()

skipMany1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m ()

spaces :: Stream s m Char => ParsecT s u m ()

space :: Stream s m Char => ParsecT s u m Char

anyChar :: Stream s m Char => ParsecT s u m Char

satisfy :: Stream s m Char => (Char -> Bool) -> ParsecT s u m Char

newline :: Stream s m Char => ParsecT s u m Char

string :: Stream s m Char => String -> ParsecT s u m String

count :: Stream s m t => Int -> ParsecT s u m a -> ParsecT s u m [a]

eof :: (Stream s m t, Show t) => ParsecT s u m ()

noneOf :: Stream s m Char => [Char] -> ParsecT s u m Char

oneOf :: Stream s m Char => [Char] -> ParsecT s u m Char

lookAhead :: Stream s m t => ParsecT s u m a -> ParsecT s u m a

notFollowedBy :: (Stream s m t, Show a) => ParsecT s u m a -> ParsecT s u m ()

many :: ParsecT s u m a -> ParsecT s u m [a]

many1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m [a]

manyTill :: Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]

(<|>) :: ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a

(<?>) :: ParsecT s u m a -> String -> ParsecT s u m a

choice :: Stream s m t => [ParsecT s u m a] -> ParsecT s u m a

try :: ParsecT s u m a -> ParsecT s u m a

sepBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

sepBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

sepEndBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

sepEndBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

endBy :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

endBy1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]

option :: Stream s m t => a -> ParsecT s u m a -> ParsecT s u m a

optional :: Stream s m t => ParsecT s u m a -> ParsecT s u m ()

optionMaybe :: Stream s m t => ParsecT s u m a -> ParsecT s u m (Maybe a)

getState :: Monad m => ParsecT s u m u

setState :: Monad m => u -> ParsecT s u m ()

updateState :: Monad m => (u -> u) -> ParsecT s u m ()

getPosition :: Monad m => ParsecT s u m SourcePos

setPosition :: Monad m => SourcePos -> ParsecT s u m ()

sourceColumn :: SourcePos -> Column

newPos :: SourceName -> Line -> Column -> SourcePos

token :: Stream s Identity t => (t -> String) -> (t -> SourcePos) -> (t -> Maybe a) -> Parsec s u a