]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
a519d34a227da9b8a40ec6db7b66108907185fc2
[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           Network.URI
22 import           Rakka.Page
23
24
25 type WikiPage = [BlockElement]
26
27
28 data Element
29     = Block  !BlockElement
30     | Inline !InlineElement
31     deriving (Eq, Show)
32
33
34 type Attribute = (String, String)
35
36
37 data BlockElement
38     = Heading {
39         headingLevel :: !Int
40       , headingText  :: !String
41       }
42     | HorizontalLine
43     | List {
44         listType  :: !ListType
45       , listItems :: ![ListItem]
46       }
47     | DefinitionList ![Definition]
48     | Preformatted ![InlineElement]
49     | Paragraph ![InlineElement]
50     | Div ![Attribute] ![Element]
51     | EmptyBlock
52     | BlockCmd !BlockCommand
53     deriving (Eq, Show)
54
55
56 data InlineElement
57     = Text !String
58     | Italic ![InlineElement]
59     | Bold ![InlineElement]
60     | ObjectLink {
61         objLinkPage :: !PageName
62       , objLinkText :: !(Maybe String)
63       }
64     | PageLink {
65         linkPage     :: !(Maybe PageName)
66       , linkFragment :: !(Maybe String)
67       , linkText     :: !(Maybe String)
68       }
69     | ExternalLink {
70         extLinkURI  :: !URI
71       , extLinkText :: !(Maybe String)
72       }
73     | LineBreak ![Attribute]
74     | Span ![Attribute] ![InlineElement]
75     | Image {
76         imgSource :: !(Either URI PageName)
77       , imgAlt    :: !(Maybe String)
78       }
79     | Anchor ![Attribute] ![InlineElement]
80     | Input ![Attribute]
81     | EmptyInline
82     | InlineCmd !InlineCommand
83     deriving (Eq, Show)
84
85
86 data ListType
87     = Bullet
88     | Numbered
89     deriving (Eq, Show)
90
91
92 type ListItem = [Element]
93
94
95 data Definition
96     = Definition {
97         defTerm :: ![InlineElement]
98       , defDesc :: ![InlineElement]
99       }
100     deriving (Eq, Show)
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)
116
117
118 data InlineCommand
119     = InlineCommand {
120         iCmdName       :: !String
121       , iCmdAttributes :: ![Attribute]
122       , iCmdContents   :: ![InlineElement]
123       }
124     deriving (Eq, Show)