Movatterモバイル変換


[0]ホーム

URL:


pandoc-1.11: 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 datastructure definitions from the Pandoc libraries.

A typical application will chain together a reader and a writerto convert strings from one format to another. For example, thefollowing simple program will act as a filter converting markdownfragments to reStructuredText, using reference-style links instead ofinline 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 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 usingfilter (/='\r').

Synopsis

Definitions

moduleText.Pandoc.Definition

Generics

moduleText.Pandoc.Generic

Options

moduleText.Pandoc.Options

Lists of readers and writers

readers :: [(String,ReaderOptions ->String ->IOPandoc)]Source

Association list of formats and readers.

writers :: [(String,Writer)]Source

Association list of formats and writers.

Readers: convertingto 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.

readLaTeXSource

Arguments

::ReaderOptions

Reader options

->String

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

->Pandoc 

Parse LaTeX from string and returnPandoc document.

readHtmlSource

Arguments

::ReaderOptions

Reader options

->String

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

->Pandoc 

Convert HTML-formatted string toPandoc document.

readTextileSource

Arguments

::ReaderOptions

Reader options

->String

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

->Pandoc 

Parse a Textile text and return a Pandoc document.

readDocBook ::ReaderOptions ->String ->PandocSource

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 (Meta [] [] []) [Plain [Str "hi"]]

Writers: convertingfrom Pandoc format

dataWriterSource

Constructors

PureStringWriter (WriterOptions ->Pandoc ->String) 
IOStringWriter (WriterOptions ->Pandoc ->IOString) 
IOByteStringWriter (WriterOptions ->Pandoc ->IOByteString) 

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

Arguments

::WriterOptions

Writer options

->Pandoc

Document to convert

->IOByteString 

Produce an ODT file from a Pandoc document.

writeDocxSource

Arguments

::WriterOptions

Writer options

->Pandoc

Document to convert

->IOByteString 

Produce an Docx file from a Pandoc document.

writeEPUBSource

Arguments

::WriterOptions

Writer options

->Pandoc

Document to convert

->IOByteString 

Produce an EPUB file from a Pandoc document.

writeFB2Source

Arguments

::WriterOptions

conversion options

->Pandoc

document to convert

->IOString

FictionBook2 document (not encoded yet)

Produce an FB2 document from aPandoc document.

writeOrg ::WriterOptions ->Pandoc ->StringSource

Convert Pandoc to Org.

writeAsciiDoc ::WriterOptions ->Pandoc ->StringSource

Convert Pandoc to AsciiDoc.

Rendering templates and default templates

moduleText.Pandoc.Templates

Version

pandocVersion ::StringSource

Version number of pandoc library.

Miscellaneous

getReader ::String ->EitherString (ReaderOptions ->String ->IOPandoc)Source

Retrieve reader based on formatSpec (format+extensions).

getWriter ::String ->EitherStringWriterSource

Retrieve writer based on formatSpec (format+extensions).

jsonFilter :: (Pandoc ->Pandoc) ->String ->StringSource

Deprecated: Use toJsonFilter instead

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.

classToJsonFilter awhereSource

toJsonFilter convert a function into a filter that reads pandoc's json output from stdin, transforms it by walking the AST and applying the specified function, and writes the result as json to stdout. Usage example:

 -- capitalize.hs -- compile with:  ghc --make capitalize -- run with:      pandoc -t json | ./capitalize | pandoc -f json import Text.Pandoc import Data.Char (toUpper) main :: IO () main = toJsonFilter capitalizeStrings capitalizeStrings :: Inline -> Inline capitalizeStrings (Str s) = Str $ map toUpper s capitalizeStrings x       = x

The function can be any type(a -> a),(a -> IO a),(a -> [a]), or(a -> IO [a]), wherea is an instance ofData. So, for example,a can bePandoc,Inline,Block, [Inline], [Block],Meta,ListNumberStyle,Alignment,ListNumberDelim,QuoteType, etc. SeeDefinition.

Methods

toJsonFilter :: a ->IO ()Source

Instances

Data a =>ToJsonFilter (a ->IO [a]) 
Data a =>ToJsonFilter (a -> [a]) 
Data a =>ToJsonFilter (a ->IO a) 
Data a =>ToJsonFilter (a -> a) 

Produced byHaddock version 2.13.2


[8]ページ先頭

©2009-2025 Movatter.jp