]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
Implemented block commands
[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     | InlineCmd !InlineCommand
52     deriving (Eq, Show)
53
54
55 data ListElement
56     = ListElement {
57         listType  :: !ListType
58       , listItems :: ![ListItem]
59       }
60     deriving (Eq, Show)
61
62
63 data ListType
64     = Bullet
65     | Numbered
66     deriving (Eq, Show)
67
68
69 type ListItem = [Either ListElement InlineElement]
70
71
72 data Definition
73     = Definition {
74         defTerm :: ![InlineElement]
75       , defDesc :: ![InlineElement]
76       }
77     deriving (Eq, Show)
78
79
80 data CommandType
81     = InlineCommandType
82     | BlockCommandType
83
84
85 type Attribute = (String, String)
86
87
88 data BlockCommand
89     = BlockCommand {
90         bCmdName       :: !String
91       , bCmdAttributes :: ![Attribute]
92       , bCmdContents   :: ![BlockElement]
93       }
94     deriving (Eq, Show)
95
96
97 data InlineCommand
98     = InlineCommand {
99         iCmdName       :: !String
100       , iCmdAttributes :: ![Attribute]
101       , iCmdContents   :: ![InlineElement]
102       }
103     deriving (Eq, Show)