pandoc-1.8.1.1: Conversion between markup formatsSource codeContentsIndex
Text.Pandoc
Portabilityportable
Stabilityalpha
MaintainerJohn MacFarlane <jgm@berkeley.edu>
Contents
Definitions
Generics
Lists of readers and writers
Readers: converting to Pandoc format
Parser state used in readers
Writers: converting from Pandoc format
Writer options used in writers
Rendering templates and default templates
Version
Miscellaneous
Description

This helper module exports the main writers, readers, and data structure definitions from the Pandoc libraries.

A typical application will chain together a reader and a writer to convert strings from one format to another. For example, the following simple program will act as a filter converting markdown fragments to reStructuredText, using reference-style links instead of inline links:

 module Main where
 import Text.Pandoc
 -- include the following two lines only if you're using ghc < 6.12:
 import Prelude hiding (getContents, putStrLn)
 import System.IO.UTF8

 markdownToRST :: String -> String
 markdownToRST =
   (writeRST defaultWriterOptions {writerReferenceLinks = True}) .
   readMarkdown defaultParserState
 
 main = getContents >>= putStrLn . markdownToRST

Note: all of the readers assume that the input text has '\n' line endings. So if you get your input text from a web form, you should remove '\r' characters using filter (/='\r').

Synopsis
module Text.Pandoc.Definition
module Text.Pandoc.Generic
readers :: [(String, ParserState -> String -> Pandoc)]
writers :: [(String, WriterOptions -> Pandoc -> String)]
readMarkdown :: ParserState -> String -> Pandoc
readRST :: ParserState -> String -> Pandoc
readLaTeX :: ParserState -> String -> Pandoc
readHtml :: ParserState -> String -> Pandoc
readTextile :: ParserState -> String -> Pandoc
readNative :: String -> Pandoc
data ParserState = ParserState {
stateParseRaw :: Bool
stateParserContext :: ParserContext
stateQuoteContext :: QuoteContext
stateKeys :: KeyTable
stateCitations :: [String]
stateNotes :: NoteTable
stateTabStop :: Int
stateStandalone :: Bool
stateTitle :: [Inline]
stateAuthors :: [[Inline]]
stateDate :: [Inline]
stateStrict :: Bool
stateSmart :: Bool
stateLiterateHaskell :: Bool
stateColumns :: Int
stateHeaderTable :: [HeaderType]
stateIndentedCodeClasses :: [String]
stateNextExample :: Int
stateExamples :: Map String Int
stateHasChapters :: Bool
stateApplyMacros :: Bool
stateMacros :: [Macro]
}
defaultParserState :: ParserState
data ParserContext
= ListItemState
| NullState
data QuoteContext
= InSingleQuote
| InDoubleQuote
| NoQuote
type KeyTable = Map Key Target
type NoteTable = [(String, String)]
data HeaderType
= SingleHeader Char
| DoubleHeader Char
writeNative :: WriterOptions -> Pandoc -> String
writeMarkdown :: WriterOptions -> Pandoc -> String
writePlain :: WriterOptions -> Pandoc -> String
writeRST :: WriterOptions -> Pandoc -> String
writeLaTeX :: WriterOptions -> Pandoc -> String
writeConTeXt :: WriterOptions -> Pandoc -> String
writeTexinfo :: WriterOptions -> Pandoc -> String
writeHtml :: WriterOptions -> Pandoc -> Html
writeHtmlString :: WriterOptions -> Pandoc -> String
writeDocbook :: WriterOptions -> Pandoc -> String
writeOpenDocument :: WriterOptions -> Pandoc -> String
writeMan :: WriterOptions -> Pandoc -> String
writeMediaWiki :: WriterOptions -> Pandoc -> String
writeTextile :: WriterOptions -> Pandoc -> String
writeRTF :: WriterOptions -> Pandoc -> String
writeODT :: Maybe FilePath -> WriterOptions -> Pandoc -> IO ByteString
writeEPUB :: Maybe String -> WriterOptions -> Pandoc -> IO ByteString
writeOrg :: WriterOptions -> Pandoc -> String
data WriterOptions = WriterOptions {
writerStandalone :: Bool
writerTemplate :: String
writerVariables :: [(String, String)]
writerEPUBMetadata :: String
writerTabStop :: Int
writerTableOfContents :: Bool
writerSlideVariant :: HTMLSlideVariant
writerIncremental :: Bool
writerXeTeX :: Bool
writerHTMLMathMethod :: HTMLMathMethod
writerIgnoreNotes :: Bool
writerNumberSections :: Bool
writerSectionDivs :: Bool
writerStrictMarkdown :: Bool
writerReferenceLinks :: Bool
writerWrapText :: Bool
writerColumns :: Int
writerLiterateHaskell :: Bool
writerEmailObfuscation :: ObfuscationMethod
writerIdentifierPrefix :: String
writerSourceDirectory :: FilePath
writerUserDataDir :: Maybe FilePath
writerCiteMethod :: CiteMethod
writerBiblioFiles :: [FilePath]
writerHtml5 :: Bool
writerChapters :: Bool
writerListings :: Bool
writerAscii :: Bool
}
data HTMLSlideVariant
= S5Slides
| SlidySlides
| NoSlides
data HTMLMathMethod
= PlainMath
| LaTeXMathML (Maybe String)
| JsMath (Maybe String)
| GladTeX
| WebTeX String
| MathML (Maybe String)
| MathJax String
data CiteMethod
= Citeproc
| Natbib
| Biblatex
defaultWriterOptions :: WriterOptions
module Text.Pandoc.Templates
pandocVersion :: String
rtfEmbedImage :: Inline -> IO Inline
jsonFilter :: (Pandoc -> Pandoc) -> String -> String
Definitions
module Text.Pandoc.Definition
Generics
module Text.Pandoc.Generic
Lists of readers and writers
readers :: [(String, ParserState -> String -> Pandoc)]Source
Association list of formats and readers.
writers :: [(String, WriterOptions -> Pandoc -> String)]Source
Association list of formats and writers (omitting the binary writers, odt and epub).
Readers: converting to Pandoc format
readMarkdownSource
:: ParserStateParser state, including options for parser
-> StringString to parse (assuming '\n' line endings)
-> Pandoc
Read markdown from an input string and return a Pandoc document.
readRSTSource
:: ParserStateParser state, including options for parser
-> StringString to parse (assuming '\n' line endings)
-> Pandoc
Parse reStructuredText string and return Pandoc document.
readLaTeXSource
:: ParserStateParser state, including options for parser
-> StringString to parse (assumes '\n' line endings)
-> Pandoc
Parse LaTeX from string and return Pandoc document.
readHtmlSource
:: ParserStateParser state
-> StringString to parse (assumes '\n' line endings)
-> Pandoc
Convert HTML-formatted string to Pandoc document.
readTextileSource
:: ParserStateParser state, including options for parser
-> StringString to parse (assuming '\n' line endings)
-> Pandoc
Parse a Textile text and return a Pandoc document.
readNativeSource
:: StringString to parse (assuming '\n' line endings)
-> Pandoc

Read native formatted text and return a Pandoc document. The input may be a full pandoc document, a block list, a block, an inline list, or an inline. Thus, for example,

 Str "hi"

will be treated as if it were

 Pandoc (Meta [] [] []) [Plain [Str "hi"]]
Parser state used in readers
data ParserState Source
Parsing options.
Constructors
ParserState
stateParseRaw :: BoolParse raw HTML and LaTeX?
stateParserContext :: ParserContextInside list?
stateQuoteContext :: QuoteContextInside quoted environment?
stateKeys :: KeyTableList of reference keys
stateCitations :: [String]List of available citations
stateNotes :: NoteTableList of notes
stateTabStop :: IntTab stop
stateStandalone :: BoolParse bibliographic info?
stateTitle :: [Inline]Title of document
stateAuthors :: [[Inline]]Authors of document
stateDate :: [Inline]Date of document
stateStrict :: BoolUse strict markdown syntax?
stateSmart :: BoolUse smart typography?
stateLiterateHaskell :: BoolTreat input as literate haskell
stateColumns :: IntNumber of columns in terminal
stateHeaderTable :: [HeaderType]Ordered list of header types used
stateIndentedCodeClasses :: [String]Classes to use for indented code blocks
stateNextExample :: IntNumber of next example
stateExamples :: Map String IntMap from example labels to numbers
stateHasChapters :: BoolTrue if chapter encountered
stateApplyMacros :: BoolApply LaTeX macros?
stateMacros :: [Macro]List of macros defined so far
show/hide Instances
defaultParserState :: ParserStateSource
data ParserContext Source
Constructors
ListItemStateUsed when running parser on list item contents
NullStateDefault state
show/hide Instances
data QuoteContext Source
Constructors
InSingleQuoteUsed when parsing inside single quotes
InDoubleQuoteUsed when parsing inside double quotes
NoQuoteUsed when not parsing inside quotes
show/hide Instances
type KeyTable = Map Key TargetSource
type NoteTable = [(String, String)]Source
data HeaderType Source
Constructors
SingleHeader CharSingle line of characters underneath
DoubleHeader CharLines of characters above and below
show/hide Instances
Writers: converting from Pandoc format
writeNative :: WriterOptions -> Pandoc -> StringSource
Prettyprint Pandoc document.
writeMarkdown :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to Markdown.
writePlain :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to plain text (like markdown, but without links, pictures, or inline formatting).
writeRST :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to RST.
writeLaTeX :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to LaTeX.
writeConTeXt :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to ConTeXt.
writeTexinfo :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to Texinfo.
writeHtml :: WriterOptions -> Pandoc -> HtmlSource
Convert Pandoc document to Html structure.
writeHtmlString :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc document to Html string.
writeDocbook :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc document to string in Docbook format.
writeOpenDocument :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc document to string in OpenDocument format.
writeMan :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to Man.
writeMediaWiki :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to MediaWiki.
writeTextile :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to Textile.
writeRTF :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to a string in rich text format.
writeODTSource
:: Maybe FilePathPath specified by --reference-odt
-> WriterOptionsWriter options
-> PandocDocument to convert
-> IO ByteString
Produce an ODT file from a Pandoc document.
writeEPUBSource
:: Maybe StringEPUB stylesheet specified at command line
-> WriterOptionsWriter options
-> PandocDocument to convert
-> IO ByteString
Produce an EPUB file from a Pandoc document.
writeOrg :: WriterOptions -> Pandoc -> StringSource
Convert Pandoc to Org.
Writer options used in writers
data WriterOptions Source
Options for writers
Constructors
WriterOptions
writerStandalone :: BoolInclude header and footer
writerTemplate :: StringTemplate to use in standalone mode
writerVariables :: [(String, String)]Variables to set in template
writerEPUBMetadata :: StringMetadata to include in EPUB
writerTabStop :: IntTabstop for conversion btw spaces and tabs
writerTableOfContents :: BoolInclude table of contents
writerSlideVariant :: HTMLSlideVariantAre we writing S5 or Slidy?
writerIncremental :: BoolTrue if lists should be incremental
writerXeTeX :: BoolCreate latex suitable for use by xetex
writerHTMLMathMethod :: HTMLMathMethodHow to print math in HTML
writerIgnoreNotes :: BoolIgnore footnotes (used in making toc)
writerNumberSections :: BoolNumber sections in LaTeX
writerSectionDivs :: BoolPut sections in div tags in HTML
writerStrictMarkdown :: BoolUse strict markdown syntax
writerReferenceLinks :: BoolUse reference links in writing markdown, rst
writerWrapText :: BoolWrap text to line length
writerColumns :: IntCharacters in a line (for text wrapping)
writerLiterateHaskell :: BoolWrite as literate haskell
writerEmailObfuscation :: ObfuscationMethodHow to obfuscate emails
writerIdentifierPrefix :: StringPrefix for section & note ids in HTML
writerSourceDirectory :: FilePathDirectory path of 1st source file
writerUserDataDir :: Maybe FilePathPath of user data directory
writerCiteMethod :: CiteMethodHow to print cites
writerBiblioFiles :: [FilePath]Biblio files to use for citations
writerHtml5 :: BoolProduce HTML5
writerChapters :: BoolUse chapter for top-level sects
writerListings :: BoolUse listings package for code
writerAscii :: BoolAvoid non-ascii characters
show/hide Instances
data HTMLSlideVariant Source
Varieties of HTML slide shows.
Constructors
S5Slides
SlidySlides
NoSlides
show/hide Instances
data HTMLMathMethod Source
Constructors
PlainMath
LaTeXMathML (Maybe String)
JsMath (Maybe String)
GladTeX
WebTeX String
MathML (Maybe String)
MathJax String
show/hide Instances
data CiteMethod Source
Constructors
Citeproc
Natbib
Biblatex
show/hide Instances
defaultWriterOptions :: WriterOptionsSource
Default writer options.
Rendering templates and default templates
module Text.Pandoc.Templates
Version
pandocVersion :: StringSource
Version number of pandoc library.
Miscellaneous
rtfEmbedImage :: Inline -> IO InlineSource
Convert Image inlines into a raw RTF embedded image, read from a file. If file not found or filetype not jpeg or png, leave the inline unchanged.
jsonFilter :: (Pandoc -> Pandoc) -> String -> StringSource
Converts a transformation on the Pandoc AST into a function that reads and writes a JSON-encoded string. This is useful for writing small scripts.
Produced by Haddock version 2.6.1