]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
5dfb462bba6a33d0559c195b5a5cb37147ab06df
[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     | Input ![Attribute]
82     | EmptyInline
83     | InlineCmd !InlineCommand
84     deriving (Eq, Show, Typeable, Data)
85
86
87 data ListType
88     = Bullet
89     | Numbered
90     deriving (Eq, Show, Typeable, Data)
91
92
93 type ListItem = [Element]
94
95
96 data Definition
97     = Definition {
98         defTerm :: ![InlineElement]
99       , defDesc :: ![InlineElement]
100       }
101     deriving (Eq, Show, Typeable, Data)
102
103
104 data CommandType
105     = InlineCommandType
106     | BlockCommandType
107     deriving (Eq, Show)
108
109
110 data BlockCommand
111     = BlockCommand {
112         bCmdName       :: !String
113       , bCmdAttributes :: ![Attribute]
114       , bCmdContents   :: ![BlockElement]
115       }
116     deriving (Eq, Show, Typeable, Data)
117
118
119 data InlineCommand
120     = InlineCommand {
121         iCmdName       :: !String
122       , iCmdAttributes :: ![Attribute]
123       , iCmdContents   :: ![InlineElement]
124       }
125     deriving (Eq, Show, Typeable, Data)