pandoc-1.13: Conversion between markup formats

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

Text.Pandoc

Contents

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

 markdownToRST :: String -> String
 markdownToRST =
   (writeRST def {writerReferenceLinks = True}) . readMarkdown def

 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

Definitions

Generics

Options

Lists of readers and writers

readers :: [(String, Reader)]Source

Association list of formats and readers.

writers :: [(String, Writer)]Source

Association list of formats and writers.

Readers: converting to Pandoc format

readMarkdownSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assuming '\n' line endings)

-> Pandoc 

Read markdown from an input string and return a Pandoc document.

readMediaWikiSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assuming '\n' line endings)

-> Pandoc 

Read mediawiki from an input string and return a Pandoc document.

readRSTSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assuming '\n' line endings)

-> Pandoc 

Parse reStructuredText string and return Pandoc document.

readOrgSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assuming '\n' line endings)

-> Pandoc 

Parse org-mode string and return a Pandoc document.

readLaTeXSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assumes '\n' line endings)

-> Pandoc 

Parse LaTeX from string and return Pandoc document.

readHtmlSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assumes '\n' line endings)

-> Pandoc 

Convert HTML-formatted string to Pandoc document.

readTextileSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse (assuming '\n' line endings)

-> Pandoc 

Parse a Textile text and return a Pandoc document.

readHaddockSource

Arguments

:: ReaderOptions

Reader options

-> String

String to parse

-> Pandoc 

Parse Haddock markup and return a Pandoc document.

readNativeSource

Arguments

:: String

String 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 nullMeta [Plain [Str "hi"]]

readTxt2Tags :: T2TMeta -> ReaderOptions -> String -> PandocSource

Read Txt2Tags from an input string returning a Pandoc document

readTxt2TagsNoMacros :: ReaderOptions -> String -> PandocSource

Read Txt2Tags (ignoring all macros) from an input string returning a Pandoc document

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.

writeICML :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc document to string in ICML format.

writeDocbook :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc document to string in Docbook format.

writeOPML :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc document to string in OPML 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.

writeDokuWiki :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to DokuWiki.

writeTextile :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to Textile.

writeRTF :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to a string in rich text format.

writeODTSource

Arguments

:: WriterOptions

Writer options

-> Pandoc

Document to convert

-> IO ByteString 

Produce an ODT file from a Pandoc document.

writeDocxSource

Arguments

:: WriterOptions

Writer options

-> Pandoc

Document to convert

-> IO ByteString 

Produce an Docx file from a Pandoc document.

writeEPUBSource

Arguments

:: WriterOptions

Writer options

-> Pandoc

Document to convert

-> IO ByteString 

Produce an EPUB file from a Pandoc document.

writeFB2Source

Arguments

:: WriterOptions

conversion options

-> Pandoc

document to convert

-> IO String

FictionBook2 document (not encoded yet)

Produce an FB2 document from a Pandoc document.

writeOrg :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to Org.

writeAsciiDoc :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to AsciiDoc.

writeHaddock :: WriterOptions -> Pandoc -> StringSource

Convert Pandoc to Haddock.

writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO StringSource

Convert Pandoc to custom markup.

Rendering templates and default templates

Version

pandocVersion :: StringSource

Version number of pandoc library.

Miscellaneous

getReader :: String -> Either String ReaderSource

Retrieve reader based on formatSpec (format+extensions).

getWriter :: String -> Either String WriterSource

Retrieve writer based on formatSpec (format+extensions).

class ToJSONFilter a => ToJsonFilter a whereSource

Deprecated. Use toJSONFilter from Text.Pandoc.JSON instead.

Methods

toJsonFilter :: a -> IO ()Source

Deprecated: Use toJSONFilter from JSON instead