]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
f0e38fedd47994f629efdd6ae1f2dbe74ac4b784
[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           Rakka.Page
20
21
22 type WikiPage = [BlockElement]
23
24
25 data BlockElement
26     = Heading {
27         headingLevel :: !Int
28       , headingText  :: !String
29       }
30     | HorizontalLine
31     | List !ListElement
32     | DefinitionList ![Definition]
33     | Preformatted ![InlineElement]
34     | Paragraph ![InlineElement]
35     | Div ![Attribute] ![BlockElement]
36     | BlockCmd !BlockCommand
37     deriving (Eq, Show)
38
39
40 data InlineElement
41     = Text !String
42     | Italic ![InlineElement]
43     | Bold ![InlineElement]
44     | PageLink {
45         linkPage     :: !(Maybe PageName)
46       , linkFragment :: !(Maybe String)
47       , linkText     :: !(Maybe String)
48       }
49     | LineBreak ![Attribute]
50     | Span ![Attribute] ![InlineElement]
51     | Image ![Attribute]
52     | Anchor ![Attribute] ![InlineElement]
53     | InlineCmd !InlineCommand
54     deriving (Eq, Show)
55
56
57 data ListElement
58     = ListElement {
59         listType  :: !ListType
60       , listItems :: ![ListItem]
61       }
62     deriving (Eq, Show)
63
64
65 data ListType
66     = Bullet
67     | Numbered
68     deriving (Eq, Show)
69
70
71 type ListItem = [Either ListElement InlineElement]
72
73
74 data Definition
75     = Definition {
76         defTerm :: ![InlineElement]
77       , defDesc :: ![InlineElement]
78       }
79     deriving (Eq, Show)
80
81
82 data CommandType
83     = InlineCommandType
84     | BlockCommandType
85
86
87 type Attribute = (String, String)
88
89
90 data BlockCommand
91     = BlockCommand {
92         bCmdName       :: !String
93       , bCmdAttributes :: ![Attribute]
94       , bCmdContents   :: ![BlockElement]
95       }
96     deriving (Eq, Show)
97
98
99 data InlineCommand
100     = InlineCommand {
101         iCmdName       :: !String
102       , iCmdAttributes :: ![Attribute]
103       , iCmdContents   :: ![InlineElement]
104       }
105     deriving (Eq, Show)