aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Definition.hs
blob: b2655ffa061617b0df929fe7dc9934db2689fa8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{- |
   Module      : Text.Pandoc.Definition
   Copyright   : Copyright (C) 2006 John MacFarlane
   License     : GNU GPL, version 2 or above 

   Maintainer  : John MacFarlane <jgm at berkeley dot edu>
   Stability   : unstable
   Portability : portable

Definition of 'Pandoc' data structure for format-neutral representation
of documents.
-}
module Text.Pandoc.Definition where

data Pandoc = Pandoc Meta [Block] deriving (Eq, Read, Show)

-- | Bibliographic information for the document:  title (list of 'Inline'),
-- authors (list of strings), date (string).
data Meta   = Meta [Inline] -- title
                   [String] -- authors
                   String   -- date
              deriving (Eq, Show, Read)

-- | Block element.
data Block  
    = Plain [Inline]        -- ^ Plain text, not a paragraph
    | Blank                 -- ^ A blank line
    | Null                  -- ^ Nothing
    | Para [Inline]         -- ^ Paragraph
    | Key [Inline] Target   -- ^ Reference key:  name (inlines) and 'Target'
    | CodeBlock String      -- ^ Code block (literal)
    | RawHtml String        -- ^ Raw HTML block (literal)
    | BlockQuote [Block]    -- ^ Block quote (list of blocks)
    | OrderedList [[Block]] -- ^ Ordered list (list of items, each 
                            -- a list of blocks)
    | BulletList [[Block]]  -- ^ Bullet list (list of items, each
                            -- a list of blocks)
    | Header Int [Inline]   -- ^ Header - level (integer) and text (inlines) 
    | HorizontalRule        -- ^ Horizontal rule
    | Note String [Block]   -- ^ Footnote or endnote - reference (string),
                            -- text (list of blocks)
    deriving (Eq, Read, Show)
               
-- | Target for a link:  either a URL or an indirect (labeled) reference.
data Target 
    = Src String String     -- ^ First string is URL, second is title
    | Ref [Inline]          -- ^ Label (list of inlines) for an indirect ref
    deriving (Show, Eq, Read)

-- | Inline elements.
data Inline 
    = Str String            -- ^ Text (string)
    | Emph [Inline]         -- ^ Emphasized text (list of inlines)
    | Strong [Inline]       -- ^ Strongly emphasized text (list of inlines)
    | Code String           -- ^ Inline code (literal)
    | Space                 -- ^ Inter-word space
    | LineBreak             -- ^ Hard line break
    | TeX String            -- ^ LaTeX code (literal)
    | HtmlInline String     -- ^ HTML code (literal)
    | Link [Inline] Target  -- ^ Hyperlink: text (list of inlines) and target
    | Image [Inline] Target -- ^ Image:  alternative text (list of inlines)
                            -- and target
    | NoteRef String        -- ^ Footnote or endnote reference
    deriving (Show, Eq, Read)