]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
Wrote many...
[Rakka.git] / Rakka / Wiki.hs
1 module Rakka.Wiki
2     ( WikiPage
3
4     , Element(..)
5     , Attribute
6
7     , BlockElement(..)
8     , InlineElement(..)
9
10     , Definition(..)
11
12     , ListType(..)
13     , ListItem
14
15     , CommandType(..)
16     , BlockCommand(..)
17     , InlineCommand(..)
18     )
19     where
20
21 import           Data.Generics
22 import           Network.URI
23 import           Rakka.Page
24
25
26 type WikiPage = [BlockElement]
27
28
29 data Element
30     = Block  !BlockElement
31     | Inline !InlineElement
32     deriving (Eq, Show, Typeable, Data)
33
34
35 type Attribute = (String, String)
36
37
38 data BlockElement
39     = Heading {
40         headingLevel :: !Int
41       , headingText  :: !String
42       }
43     | HorizontalLine
44     | List {
45         listType  :: !ListType
46       , listItems :: ![ListItem]
47       }
48     | DefinitionList ![Definition]
49     | Preformatted ![InlineElement]
50     | Paragraph ![InlineElement]
51     | Div ![Attribute] ![Element]
52     | EmptyBlock
53     | BlockCmd !BlockCommand
54     deriving (Eq, Show, Typeable, Data)
55
56
57 data InlineElement
58     = Text !String
59     | Italic ![InlineElement]
60     | Bold ![InlineElement]
61     | ObjectLink {
62         objLinkPage :: !PageName
63       , objLinkText :: !(Maybe String)
64       }
65     | PageLink {
66         linkPage     :: !(Maybe PageName)
67       , linkFragment :: !(Maybe String)
68       , linkText     :: !(Maybe String)
69       }
70     | ExternalLink {
71         extLinkURI  :: !URI
72       , extLinkText :: !(Maybe String)
73       }
74     | LineBreak ![Attribute]
75     | Span ![Attribute] ![InlineElement]
76     | Image {
77         imgSource :: !PageName
78       , imgAlt    :: !(Maybe String)
79       }
80     | Anchor ![Attribute] ![InlineElement]
81     | EmptyInline
82     | InlineCmd !InlineCommand
83     deriving (Eq, Show, Typeable, Data)
84
85
86 data ListType
87     = Bullet
88     | Numbered
89     deriving (Eq, Show, Typeable, Data)
90
91
92 type ListItem = [Element]
93
94
95 data Definition
96     = Definition {
97         defTerm :: ![InlineElement]
98       , defDesc :: ![InlineElement]
99       }
100     deriving (Eq, Show, Typeable, Data)
101
102
103 data CommandType
104     = InlineCommandType
105     | BlockCommandType
106     deriving (Eq, Show)
107
108
109 data BlockCommand
110     = BlockCommand {
111         bCmdName       :: !String
112       , bCmdAttributes :: ![Attribute]
113       , bCmdContents   :: ![BlockElement]
114       }
115     deriving (Eq, Show, Typeable, Data)
116
117
118 data InlineCommand
119     = InlineCommand {
120         iCmdName       :: !String
121       , iCmdAttributes :: ![Attribute]
122       , iCmdContents   :: ![InlineElement]
123       }
124     deriving (Eq, Show, Typeable, Data)