-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Types for representing a structured document
--   
--   This package contains definitions for the <a>Pandoc</a> data
--   structure, which is used by pandoc to represent structured documents.
--   These definitions used to live in the pandoc package, but starting
--   with pandoc 1.7, they have been split off, so that other packages can
--   use them without drawing in all of pandoc's dependencies, and pandoc
--   itself can depend on packages (like citeproc-hs) that use them.
--   
--   <tt>Text.Pandoc.Builder</tt> provides functions for building up
--   <tt>Pandoc</tt> structures programmatically.
--   
--   <tt>Text.Pandoc.Generic</tt> provides generic functions for
--   manipulating Pandoc documents.
@package pandoc-types
@version 1.10


-- | Generic functions for manipulating <tt>Pandoc</tt> documents.
--   
--   Here's a simple example, defining a function that replaces all the
--   level 3+ headers in a document with regular paragraphs in ALL CAPS:
--   
--   <pre>
--   import Text.Pandoc.Definition
--   import Text.Pandoc.Generic
--   import Data.Char (toUpper)
--   
--   modHeader :: Block -&gt; Block
--   modHeader (Header n xs) | n &gt;= 3 = Para $ bottomUp allCaps xs
--   modHeader x = x
--   
--   allCaps :: Inline -&gt; Inline
--   allCaps (Str xs) = Str $ map toUpper xs
--   allCaps x = x
--   
--   changeHeaders :: Pandoc -&gt; Pandoc
--   changeHeaders = bottomUp modHeader
--   </pre>
--   
--   <a>bottomUp</a> is so called because it traverses the <tt>Pandoc</tt>
--   structure from bottom up. <a>topDown</a> goes the other way. The
--   difference between them can be seen from this example:
--   
--   <pre>
--   normal :: [Inline] -&gt; [Inline]
--   normal (Space : Space : xs) = Space : xs
--   normal (Emph xs : Emph ys : zs) = Emph (xs ++ ys) : zs
--   normal xs = xs
--   
--   myDoc :: Pandoc
--   myDoc =  Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
--    [Para [Str "Hi",Space,Emph [Str "world",Space],Emph [Space,Str "emphasized"]]]
--   </pre>
--   
--   Here we want to use <a>topDown</a> to lift <tt>normal</tt> to
--   <tt>Pandoc -&gt; Pandoc</tt>. The top down strategy will collapse the
--   two adjacent <tt>Emph</tt>s first, then collapse the resulting
--   adjacent <tt>Space</tt>s, as desired. If we used <a>bottomUp</a>, we
--   would end up with two adjacent <tt>Space</tt>s, since the contents of
--   the two <tt>Emph</tt> inlines would be processed before the
--   <tt>Emph</tt>s were collapsed into one.
--   
--   <pre>
--   topDown normal myDoc ==
--     Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
--      [Para [Str "Hi",Space,Emph [Str "world",Space,Str "emphasized"]]]
--   
--   bottomUp normal myDoc ==
--     Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
--      [Para [Str "Hi",Space,Emph [Str "world",Space,Space,Str "emphasized"]]]
--   </pre>
--   
--   <a>bottomUpM</a> is a monadic version of <a>bottomUp</a>. It could be
--   used, for example, to replace the contents of delimited code blocks
--   with attribute <tt>include=FILENAME</tt> with the contents of
--   <tt>FILENAME</tt>:
--   
--   <pre>
--   doInclude :: Block -&gt; IO Block
--   doInclude cb@(CodeBlock (id, classes, namevals) contents) =
--     case lookup "include" namevals of
--          Just f  -&gt; return . (CodeBlock (id, classes, namevals)) =&lt;&lt; readFile f
--          Nothing -&gt; return cb
--   doInclude x = return x
--   
--   processIncludes :: Pandoc -&gt; IO Pandoc
--   processIncludes = bottomUpM doInclude
--   </pre>
--   
--   <a>queryWith</a> can be used, for example, to compile a list of URLs
--   linked to in a document:
--   
--   <pre>
--   extractURL :: Inline -&gt; [String]
--   extractURL (Link _ (u,_)) = [u]
--   extractURL (Image _ (u,_)) = [u]
--   extractURL _ = []
--   
--   extractURLs :: Pandoc -&gt; [String]
--   extractURLs = queryWith extractURL
--   </pre>
module Text.Pandoc.Generic

-- | Applies a transformation on <tt>a</tt>s to matching elements in a
--   <tt>b</tt>, moving from the bottom of the structure up.
bottomUp :: (Data a, Data b) => (a -> a) -> b -> b

-- | Applies a transformation on <tt>a</tt>s to matching elements in a
--   <tt>b</tt>, moving from the top of the structure down.
topDown :: (Data a, Data b) => (a -> a) -> b -> b

-- | Like <a>bottomUp</a>, but with monadic transformations.
bottomUpM :: (Monad m, Data a, Data b) => (a -> m a) -> b -> m b

-- | Runs a query on matching <tt>a</tt> elements in a <tt>c</tt>. The
--   results of the queries are combined using <a>mappend</a>.
queryWith :: (Data a, Monoid b, Data c) => (a -> b) -> c -> b

-- | Deprecated synonym for <tt>bottomUp</tt>.

-- | <i>Deprecated: Use bottomUp instead </i>
processWith :: (Data a, Data b) => (a -> a) -> b -> b

-- | Deprecated synonym for <tt>bottomUpM</tt>.

-- | <i>Deprecated: Use bottomUpM instead </i>
processWithM :: (Monad m, Data a, Data b) => (a -> m a) -> b -> m b


-- | Definition of <a>Pandoc</a> data structure for format-neutral
--   representation of documents.
module Text.Pandoc.Definition
data Pandoc
Pandoc :: Meta -> [Block] -> Pandoc

-- | Bibliographic information for the document: title, authors, date.
data Meta
Meta :: [Inline] -> [[Inline]] -> [Inline] -> Meta
docTitle :: Meta -> [Inline]
docAuthors :: Meta -> [[Inline]]
docDate :: Meta -> [Inline]

-- | Alignment of a table column.
data Alignment
AlignLeft :: Alignment
AlignRight :: Alignment
AlignCenter :: Alignment
AlignDefault :: Alignment

-- | List attributes.
type ListAttributes = (Int, ListNumberStyle, ListNumberDelim)

-- | Style of list numbers.
data ListNumberStyle
DefaultStyle :: ListNumberStyle
Example :: ListNumberStyle
Decimal :: ListNumberStyle
LowerRoman :: ListNumberStyle
UpperRoman :: ListNumberStyle
LowerAlpha :: ListNumberStyle
UpperAlpha :: ListNumberStyle

-- | Delimiter of list numbers.
data ListNumberDelim
DefaultDelim :: ListNumberDelim
Period :: ListNumberDelim
OneParen :: ListNumberDelim
TwoParens :: ListNumberDelim

-- | Attributes: identifier, classes, key-value pairs
type Attr = (String, [String], [(String, String)])
nullAttr :: Attr

-- | Table cells are list of Blocks
type TableCell = [Block]

-- | Formats for raw blocks
type Format = String

-- | Block element.
data Block

-- | Plain text, not a paragraph
Plain :: [Inline] -> Block

-- | Paragraph
Para :: [Inline] -> Block

-- | Code block (literal) with attributes
CodeBlock :: Attr -> String -> Block

-- | Raw block
RawBlock :: Format -> String -> Block

-- | Block quote (list of blocks)
BlockQuote :: [Block] -> Block

-- | Ordered list (attributes and a list of items, each a list of blocks)
OrderedList :: ListAttributes -> [[Block]] -> Block

-- | Bullet list (list of items, each a list of blocks)
BulletList :: [[Block]] -> Block

-- | Definition list Each list item is a pair consisting of a term (a list
--   of inlines) and one or more definitions (each a list of blocks)
DefinitionList :: [([Inline], [[Block]])] -> Block

-- | Header - level (integer) and text (inlines)
Header :: Int -> Attr -> [Inline] -> Block

-- | Horizontal rule
HorizontalRule :: Block

-- | Table, with caption, column alignments, relative column widths (0 =
--   default), column headers (each a list of blocks), and rows (each a
--   list of lists of blocks)
Table :: [Inline] -> [Alignment] -> [Double] -> [TableCell] -> [[TableCell]] -> Block

-- | Nothing
Null :: Block

-- | Type of quotation marks to use in Quoted inline.
data QuoteType
SingleQuote :: QuoteType
DoubleQuote :: QuoteType

-- | Link target (URL, title).
type Target = (String, String)

-- | Type of math element (display or inline).
data MathType
DisplayMath :: MathType
InlineMath :: MathType

-- | Inline elements.
data Inline

-- | Text (string)
Str :: String -> Inline

-- | Emphasized text (list of inlines)
Emph :: [Inline] -> Inline

-- | Strongly emphasized text (list of inlines)
Strong :: [Inline] -> Inline

-- | Strikeout text (list of inlines)
Strikeout :: [Inline] -> Inline

-- | Superscripted text (list of inlines)
Superscript :: [Inline] -> Inline

-- | Subscripted text (list of inlines)
Subscript :: [Inline] -> Inline

-- | Small caps text (list of inlines)
SmallCaps :: [Inline] -> Inline

-- | Quoted text (list of inlines)
Quoted :: QuoteType -> [Inline] -> Inline

-- | Citation (list of inlines)
Cite :: [Citation] -> [Inline] -> Inline

-- | Inline code (literal)
Code :: Attr -> String -> Inline

-- | Inter-word space
Space :: Inline

-- | Hard line break
LineBreak :: Inline

-- | TeX math (literal)
Math :: MathType -> String -> Inline

-- | Raw inline
RawInline :: Format -> String -> Inline

-- | Hyperlink: text (list of inlines), target
Link :: [Inline] -> Target -> Inline

-- | Image: alt text (list of inlines), target
Image :: [Inline] -> Target -> Inline

-- | Footnote or endnote
Note :: [Block] -> Inline
data Citation
Citation :: String -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
citationId :: Citation -> String
citationPrefix :: Citation -> [Inline]
citationSuffix :: Citation -> [Inline]
citationMode :: Citation -> CitationMode
citationNoteNum :: Citation -> Int
citationHash :: Citation -> Int
data CitationMode
AuthorInText :: CitationMode
SuppressAuthor :: CitationMode
NormalCitation :: CitationMode
instance Typeable Alignment
instance Typeable ListNumberStyle
instance Typeable ListNumberDelim
instance Typeable QuoteType
instance Typeable MathType
instance Typeable CitationMode
instance Typeable Citation
instance Typeable Inline
instance Typeable Block
instance Typeable Meta
instance Typeable Pandoc
instance Eq Alignment
instance Ord Alignment
instance Show Alignment
instance Read Alignment
instance Data Alignment
instance Generic Alignment
instance Eq ListNumberStyle
instance Ord ListNumberStyle
instance Show ListNumberStyle
instance Read ListNumberStyle
instance Data ListNumberStyle
instance Generic ListNumberStyle
instance Eq ListNumberDelim
instance Ord ListNumberDelim
instance Show ListNumberDelim
instance Read ListNumberDelim
instance Data ListNumberDelim
instance Generic ListNumberDelim
instance Show QuoteType
instance Eq QuoteType
instance Ord QuoteType
instance Read QuoteType
instance Data QuoteType
instance Generic QuoteType
instance Show MathType
instance Eq MathType
instance Ord MathType
instance Read MathType
instance Data MathType
instance Generic MathType
instance Show CitationMode
instance Eq CitationMode
instance Ord CitationMode
instance Read CitationMode
instance Data CitationMode
instance Generic CitationMode
instance Show Citation
instance Eq Citation
instance Read Citation
instance Data Citation
instance Generic Citation
instance Show Inline
instance Eq Inline
instance Ord Inline
instance Read Inline
instance Data Inline
instance Generic Inline
instance Eq Block
instance Ord Block
instance Read Block
instance Show Block
instance Data Block
instance Generic Block
instance Eq Meta
instance Ord Meta
instance Show Meta
instance Read Meta
instance Data Meta
instance Generic Meta
instance Eq Pandoc
instance Ord Pandoc
instance Read Pandoc
instance Show Pandoc
instance Data Pandoc
instance Generic Pandoc
instance Datatype D1Alignment
instance Constructor C1_0Alignment
instance Constructor C1_1Alignment
instance Constructor C1_2Alignment
instance Constructor C1_3Alignment
instance Datatype D1ListNumberStyle
instance Constructor C1_0ListNumberStyle
instance Constructor C1_1ListNumberStyle
instance Constructor C1_2ListNumberStyle
instance Constructor C1_3ListNumberStyle
instance Constructor C1_4ListNumberStyle
instance Constructor C1_5ListNumberStyle
instance Constructor C1_6ListNumberStyle
instance Datatype D1ListNumberDelim
instance Constructor C1_0ListNumberDelim
instance Constructor C1_1ListNumberDelim
instance Constructor C1_2ListNumberDelim
instance Constructor C1_3ListNumberDelim
instance Datatype D1QuoteType
instance Constructor C1_0QuoteType
instance Constructor C1_1QuoteType
instance Datatype D1MathType
instance Constructor C1_0MathType
instance Constructor C1_1MathType
instance Datatype D1CitationMode
instance Constructor C1_0CitationMode
instance Constructor C1_1CitationMode
instance Constructor C1_2CitationMode
instance Datatype D1Citation
instance Constructor C1_0Citation
instance Selector S1_0_0Citation
instance Selector S1_0_1Citation
instance Selector S1_0_2Citation
instance Selector S1_0_3Citation
instance Selector S1_0_4Citation
instance Selector S1_0_5Citation
instance Datatype D1Inline
instance Constructor C1_0Inline
instance Constructor C1_1Inline
instance Constructor C1_2Inline
instance Constructor C1_3Inline
instance Constructor C1_4Inline
instance Constructor C1_5Inline
instance Constructor C1_6Inline
instance Constructor C1_7Inline
instance Constructor C1_8Inline
instance Constructor C1_9Inline
instance Constructor C1_10Inline
instance Constructor C1_11Inline
instance Constructor C1_12Inline
instance Constructor C1_13Inline
instance Constructor C1_14Inline
instance Constructor C1_15Inline
instance Constructor C1_16Inline
instance Datatype D1Block
instance Constructor C1_0Block
instance Constructor C1_1Block
instance Constructor C1_2Block
instance Constructor C1_3Block
instance Constructor C1_4Block
instance Constructor C1_5Block
instance Constructor C1_6Block
instance Constructor C1_7Block
instance Constructor C1_8Block
instance Constructor C1_9Block
instance Constructor C1_10Block
instance Constructor C1_11Block
instance Datatype D1Meta
instance Constructor C1_0Meta
instance Selector S1_0_0Meta
instance Selector S1_0_1Meta
instance Selector S1_0_2Meta
instance Datatype D1Pandoc
instance Constructor C1_0Pandoc
instance Ord Citation


-- | Convenience functions for building pandoc documents programmatically.
--   
--   Example of use:
--   
--   <pre>
--   
--   import Text.Pandoc.Builder
--   
--   myDoc :: Pandoc
--   myDoc = setTitle "My title" $ doc $
--     para "This is the first paragraph" &lt;&gt;
--     para ("And " &lt;&gt; emph "another" &lt;&gt; ".") &lt;&gt;
--     bulletList [ para "item one" &lt;&gt; para "continuation"
--                , plain ("item two and a " &lt;&gt;
--                    link "/url" "go to url" "link")
--                ]
--   </pre>
--   
--   Isn't that nicer than writing the following?
--   
--   <pre>
--   import Text.Pandoc.Definition
--   
--   myDoc :: Pandoc
--   myDoc = Pandoc (Meta {docTitle = [Str "My",Space,Str "title"]
--                        , docAuthors = []
--                        , docDate = []})
--    [Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "first",
--     Space,Str "paragraph"]
--    ,Para [Str "And",Space,Emph [Str "another"],Str "."]
--    ,BulletList [[Para [Str "item",Space,Str "one"]
--                 ,Para [Str "continuation"]]
--                ,[Plain [Str "item",Space,Str "two",Space,Str "and", Space,
--                   Str "a",Space,Link [Str "link"] ("/url","go to url")]]]]
--   </pre>
--   
--   And of course, you can use Haskell to define your own builders:
--   
--   <pre>
--   import Text.Pandoc.Builder
--   import Text.JSON
--   import Control.Arrow ((***))
--   import Data.Monoid (mempty)
--   
--   -- | Converts a JSON document into 'Blocks'.
--   json :: String -&gt; Blocks
--   json x =
--     case decode x of
--          Ok y    -&gt; jsValueToBlocks y
--          Error y -&gt; error y
--      where jsValueToBlocks x =
--             case x of
--              JSNull         -&gt; mempty
--              JSBool x       -&gt; plain $ text $ show x
--              JSRational _ x -&gt; plain $ text $ show x
--              JSString x     -&gt; plain $ text $ fromJSString x
--              JSArray xs     -&gt; bulletList $ map jsValueToBlocks xs
--              JSObject x     -&gt; definitionList $
--                                 map (text *** (:[]) . jsValueToBlocks) $
--                                 fromJSObject x
--   </pre>
module Text.Pandoc.Builder
newtype Many a
Many :: Seq a -> Many a
unMany :: Many a -> Seq a
type Inlines = Many Inline
type Blocks = Many Block

-- | An infix synonym for <a>mappend</a>.
(<>) :: Monoid m => m -> m -> m
singleton :: a -> Many a
toList :: Many a -> [a]
fromList :: [a] -> Many a
isNull :: Many a -> Bool
doc :: Blocks -> Pandoc
setTitle :: Inlines -> Pandoc -> Pandoc
setAuthors :: [Inlines] -> Pandoc -> Pandoc
setDate :: Inlines -> Pandoc -> Pandoc

-- | Convert a <a>String</a> to <a>Inlines</a>, treating interword spaces
--   as <a>Space</a>s. If you want a <a>Str</a> with literal spaces, use
--   <a>str</a>.
text :: String -> Inlines
str :: String -> Inlines
emph :: Inlines -> Inlines
strong :: Inlines -> Inlines
strikeout :: Inlines -> Inlines
superscript :: Inlines -> Inlines
subscript :: Inlines -> Inlines
smallcaps :: Inlines -> Inlines
singleQuoted :: Inlines -> Inlines
doubleQuoted :: Inlines -> Inlines
cite :: [Citation] -> Inlines -> Inlines

-- | Inline code with attributes.
codeWith :: Attr -> String -> Inlines

-- | Plain inline code.
code :: String -> Inlines
space :: Inlines
linebreak :: Inlines

-- | Inline math
math :: String -> Inlines

-- | Display math
displayMath :: String -> Inlines
rawInline :: Format -> String -> Inlines
link :: String -> String -> Inlines -> Inlines
image :: String -> String -> Inlines -> Inlines
note :: Blocks -> Inlines

-- | Trim leading and trailing Sp (spaces) from an Inlines.
trimInlines :: Inlines -> Inlines
para :: Inlines -> Blocks
plain :: Inlines -> Blocks

-- | A code block with attributes.
codeBlockWith :: Attr -> String -> Blocks

-- | A plain code block.
codeBlock :: String -> Blocks
rawBlock :: Format -> String -> Blocks
blockQuote :: Blocks -> Blocks
bulletList :: [Blocks] -> Blocks

-- | Ordered list with attributes.
orderedListWith :: ListAttributes -> [Blocks] -> Blocks

-- | Ordered list with default attributes.
orderedList :: [Blocks] -> Blocks
definitionList :: [(Inlines, [Blocks])] -> Blocks
header :: Int -> Inlines -> Blocks
headerWith :: Attr -> Int -> Inlines -> Blocks
horizontalRule :: Blocks
table :: Inlines -> [(Alignment, Double)] -> [Blocks] -> [[Blocks]] -> Blocks

-- | A simple table without a caption.
simpleTable :: [Blocks] -> [[Blocks]] -> Blocks
instance Typeable1 Many
instance Monoid (Many Block)
instance Generic (Many a)
instance Data a => Data (Many a)
instance Ord a => Ord (Many a)
instance Eq a => Eq (Many a)
instance Foldable Many
instance Traversable Many
instance Functor Many
instance Show a => Show (Many a)
instance Read a => Read (Many a)
instance Datatype D1Many
instance Constructor C1_0Many
instance Selector S1_0_0Many
instance IsString Inlines
instance Monoid Inlines
