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