Copyright | Copyright (C) 2006-2014 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
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')
.
- module Text.Pandoc.Definition
- module Text.Pandoc.Generic
- module Text.Pandoc.Options
- readers :: [(String, Reader)]
- writers :: [(String, Writer)]
- data Reader
- = StringReader (ReaderOptions -> String -> IO Pandoc)
- | ByteStringReader (ReaderOptions -> ByteString -> IO (Pandoc, MediaBag))
- mkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader
- readMarkdown :: ReaderOptions -> String -> Pandoc
- readLaTeX :: ReaderOptions -> String -> Pandoc
- readHtml :: ReaderOptions -> String -> Pandoc
- readNative :: String -> Pandoc
- readJSON :: ReaderOptions -> String -> Pandoc
- data Writer
- = PureStringWriter (WriterOptions -> Pandoc -> String)
- | IOStringWriter (WriterOptions -> Pandoc -> IO String)
- | IOByteStringWriter (WriterOptions -> Pandoc -> IO ByteString)
- writeNative :: WriterOptions -> Pandoc -> String
- writeJSON :: WriterOptions -> Pandoc -> String
- writeMarkdown :: WriterOptions -> Pandoc -> String
- writePlain :: WriterOptions -> Pandoc -> String
- writeLaTeX :: WriterOptions -> Pandoc -> String
- writeHtml :: WriterOptions -> Pandoc -> Html
- writeHtmlString :: WriterOptions -> Pandoc -> String
- writeMan :: WriterOptions -> Pandoc -> String
- writeDocx :: WriterOptions -> Pandoc -> IO ByteString
- writeHaddock :: WriterOptions -> Pandoc -> String
- writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String
- module Text.Pandoc.Templates
- pandocVersion :: String
- getReader :: String -> Either String Reader
- getWriter :: String -> Either String Writer
- class ToJSONFilter a => ToJsonFilter a where
- toJsonFilter :: a -> IO ()
Definitions
module Text.Pandoc.Definition
Generics
module Text.Pandoc.Generic
Options
module Text.Pandoc.Options
Lists of readers and writers
Readers: converting to Pandoc format
StringReader (ReaderOptions -> String -> IO Pandoc) | |
ByteStringReader (ReaderOptions -> ByteString -> IO (Pandoc, MediaBag)) |
mkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader Source
:: ReaderOptions | Reader options |
-> String | String to parse (assuming |
-> Pandoc |
Read markdown from an input string and return a Pandoc document.
:: ReaderOptions | Reader options |
-> String | String to parse (assumes |
-> Pandoc |
Parse LaTeX from string and return Pandoc
document.
:: ReaderOptions | Reader options |
-> String | String to parse (assumes |
-> Pandoc |
Convert HTML-formatted string to Pandoc
document.
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"]]
readJSON :: ReaderOptions -> String -> Pandoc Source
Writers: converting from Pandoc format
PureStringWriter (WriterOptions -> Pandoc -> String) | |
IOStringWriter (WriterOptions -> Pandoc -> IO String) | |
IOByteStringWriter (WriterOptions -> Pandoc -> IO ByteString) |
writeNative :: WriterOptions -> Pandoc -> String Source
Prettyprint Pandoc document.
writeJSON :: WriterOptions -> Pandoc -> String Source
writeMarkdown :: WriterOptions -> Pandoc -> String Source
Convert Pandoc to Markdown.
writePlain :: WriterOptions -> Pandoc -> String Source
Convert Pandoc to plain text (like markdown, but without links, pictures, or inline formatting).
writeLaTeX :: WriterOptions -> Pandoc -> String Source
Convert Pandoc to LaTeX.
writeHtml :: WriterOptions -> Pandoc -> Html Source
Convert Pandoc document to Html structure.
writeHtmlString :: WriterOptions -> Pandoc -> String Source
Convert Pandoc document to Html string.
writeMan :: WriterOptions -> Pandoc -> String Source
Convert Pandoc to Man.
:: WriterOptions | Writer options |
-> Pandoc | Document to convert |
-> IO ByteString |
Produce an Docx file from a Pandoc document.
writeHaddock :: WriterOptions -> Pandoc -> String Source
Convert Pandoc to Haddock.
writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String Source
Convert Pandoc to custom markup.
Rendering templates and default templates
module Text.Pandoc.Templates
Version
pandocVersion :: String Source
Version number of pandoc library.
Miscellaneous
getReader :: String -> Either String Reader Source
Retrieve reader based on formatSpec (format+extensions).
getWriter :: String -> Either String Writer Source
Retrieve writer based on formatSpec (format+extensions).
class ToJSONFilter a => ToJsonFilter a where Source
Deprecated. Use toJSONFilter
from Text.Pandoc.JSON
instead.
Nothing
toJsonFilter :: a -> IO () Source
Deprecated: Use toJSONFilter
from JSON
instead