@@ -1,165 +0,0 @@
1−{-# OPTIONS_GHC -fglasgow-exts #-} -- for deriving Typeable
2−{-
3−Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
4−
5−This program is free software; you can redistribute it and/or modify
6−it under the terms of the GNU General Public License as published by
7−the Free Software Foundation; either version 2 of the License, or
8−(at your option) any later version.
9−
10−This program is distributed in the hope that it will be useful,
11−but WITHOUT ANY WARRANTY; without even the implied warranty of
12−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13−GNU General Public License for more details.
14−
15−You should have received a copy of the GNU General Public License
16−along with this program; if not, write to the Free Software
17−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18−-}
19−
20−{- |
21− Module : Text.Pandoc.Definition
22− Copyright : Copyright (C) 2006-2010 John MacFarlane
23− License : GNU GPL, version 2 or above
24−
25− Maintainer : John MacFarlane <jgm@berkeley.edu>
26− Stability : alpha
27− Portability : portable
28−
29−Definition of 'Pandoc' data structure for format-neutral representation
30−of documents.
31−-}
32−module Text.Pandoc.Definition where
33−
34−import Data.Generics
35−
36−data Pandoc = Pandoc Meta [Block] deriving (Eq, Ord, Read, Show, Typeable, Data)
37−
38−-- | Bibliographic information for the document: title, authors, date.
39−data Meta = Meta { docTitle :: [Inline]
40− , docAuthors :: [[Inline]]
41− , docDate :: [Inline] }
42− deriving (Eq, Ord, Show, Read, Typeable, Data)
43−
44−-- | Alignment of a table column.
45−data Alignment = AlignLeft
46− | AlignRight
47− | AlignCenter
48− | AlignDefault deriving (Eq, Ord, Show, Read, Typeable, Data)
49−
50−-- | List attributes.
51−type ListAttributes = (Int, ListNumberStyle, ListNumberDelim)
52−
53−-- | Style of list numbers.
54−data ListNumberStyle = DefaultStyle
55− | Example
56− | Decimal
57− | LowerRoman
58− | UpperRoman
59− | LowerAlpha
60− | UpperAlpha deriving (Eq, Ord, Show, Read, Typeable, Data)
61−
62−-- | Delimiter of list numbers.
63−data ListNumberDelim = DefaultDelim
64− | Period
65− | OneParen
66− | TwoParens deriving (Eq, Ord, Show, Read, Typeable, Data)
67−
68−-- | Attributes: identifier, classes, key-value pairs
69−type Attr = (String, [String], [(String, String)])
70−
71−-- | Block element.
72−data Block
73− = Plain [Inline] -- ^ Plain text, not a paragraph
74− | Para [Inline] -- ^ Paragraph
75− | CodeBlock Attr String -- ^ Code block (literal) with attributes
76− | RawHtml String -- ^ Raw HTML block (literal)
77− | BlockQuote [Block] -- ^ Block quote (list of blocks)
78− | OrderedList ListAttributes [[Block]] -- ^ Ordered list (attributes
79− -- and a list of items, each a list of blocks)
80− | BulletList [[Block]] -- ^ Bullet list (list of items, each
81− -- a list of blocks)
82− | DefinitionList [([Inline],[[Block]])] -- ^ Definition list
83− -- Each list item is a pair consisting of a
84− -- term (a list of inlines) and one or more
85− -- definitions (each a list of blocks)
86− | Header Int [Inline] -- ^ Header - level (integer) and text (inlines)
87− | HorizontalRule -- ^ Horizontal rule
88− | Table [Inline] [Alignment] [Double] [[Block]] [[[Block]]] -- ^ Table,
89− -- with caption, column alignments,
90− -- relative column widths (0 = default),
91− -- column headers (each a list of blocks), and
92− -- rows (each a list of lists of blocks)
93− | Null -- ^ Nothing
94− deriving (Eq, Ord, Read, Show, Typeable, Data)
95−
96−-- | Type of quotation marks to use in Quoted inline.
97−data QuoteType = SingleQuote | DoubleQuote deriving (Show, Eq, Ord, Read, Typeable, Data)
98−
99−-- | Link target (URL, title).
100−type Target = (String, String)
101−
102−-- | Type of math element (display or inline).
103−data MathType = DisplayMath | InlineMath deriving (Show, Eq, Ord, Read, Typeable, Data)
104−
105−-- | Inline elements.
106−data Inline
107− = Str String -- ^ Text (string)
108− | Emph [Inline] -- ^ Emphasized text (list of inlines)
109− | Strong [Inline] -- ^ Strongly emphasized text (list of inlines)
110− | Strikeout [Inline] -- ^ Strikeout text (list of inlines)
111− | Superscript [Inline] -- ^ Superscripted text (list of inlines)
112− | Subscript [Inline] -- ^ Subscripted text (list of inlines)
113− | SmallCaps [Inline] -- ^ Small caps text (list of inlines)
114− | Quoted QuoteType [Inline] -- ^ Quoted text (list of inlines)
115− | Cite [Citation] [Inline] -- ^ Citation (list of inlines)
116− | Code String -- ^ Inline code (literal)
117− | Space -- ^ Inter-word space
118− | EmDash -- ^ Em dash
119− | EnDash -- ^ En dash
120− | Apostrophe -- ^ Apostrophe
121− | Ellipses -- ^ Ellipses
122− | LineBreak -- ^ Hard line break
123− | Math MathType String -- ^ TeX math (literal)
124− | TeX String -- ^ LaTeX code (literal)
125− | HtmlInline String -- ^ HTML code (literal)
126− | Link [Inline] Target -- ^ Hyperlink: text (list of inlines), target
127− | Image [Inline] Target -- ^ Image: alt text (list of inlines), target
128− -- and target
129− | Note [Block] -- ^ Footnote or endnote
130− deriving (Show, Eq, Ord, Read, Typeable, Data)
131−
132−data Citation = Citation { citationId :: String
133− , citationPrefix :: String
134− , citationLocator :: String
135− , citationNoteNum :: Int
136− , citationAutOnly :: Bool
137− , citationNoAut :: Bool
138− , citationHash :: Int
139− }
140− deriving (Show, Ord, Read, Typeable, Data)
141−
142−instance Eq Citation where
143− (==) (Citation _ _ _ _ _ _ ha)
144− (Citation _ _ _ _ _ _ hb) = ha == hb
145−
146−-- | Applies a transformation on @a@s to matching elements in a @b@.
147−processWith :: (Data a, Data b) => (a -> a) -> b -> b
148−processWith f = everywhere (mkT f)
149−
150−-- | Like 'processWith', but with monadic transformations.
151−processWithM :: (Monad m, Data a, Data b) => (a -> m a) -> b -> m b
152−processWithM f = everywhereM (mkM f)
153−
154−-- | Runs a query on matching @a@ elements in a @c@.
155−queryWith :: (Data a, Data c) => (a -> [b]) -> c -> [b]
156−queryWith f = everything (++) ([] `mkQ` f)
157−
158−{-# DEPRECATED processPandoc "Use processWith instead" #-}
159−processPandoc :: Data a => (a -> a) -> Pandoc -> Pandoc
160−processPandoc = processWith
161−
162−{-# DEPRECATED queryPandoc "Use queryWith instead" #-}
163−queryPandoc :: Data a => (a -> [b]) -> Pandoc -> [b]
164−queryPandoc = queryWith
165−