]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
f8341ec8506d6069e4a152d4db50371b5bcaee1b
[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     | BlockCmd !BlockCommand
39     deriving (Eq, Show, Typeable, Data)
40
41
42 data InlineElement
43     = Text !String
44     | Italic ![InlineElement]
45     | Bold ![InlineElement]
46     | PageLink {
47         linkPage     :: !(Maybe PageName)
48       , linkFragment :: !(Maybe String)
49       , linkText     :: !(Maybe String)
50       }
51     | ExternalLink {
52         extLinkURI  :: !URI
53       , extLinkText :: !(Maybe String)
54       }
55     | LineBreak ![Attribute]
56     | Span ![Attribute] ![InlineElement]
57     | Image ![Attribute]
58     | Anchor ![Attribute] ![InlineElement]
59     | InlineCmd !InlineCommand
60     deriving (Eq, Show, Typeable, Data)
61
62
63 data ListElement
64     = ListElement {
65         listType  :: !ListType
66       , listItems :: ![ListItem]
67       }
68     deriving (Eq, Show, Typeable, Data)
69
70
71 data ListType
72     = Bullet
73     | Numbered
74     deriving (Eq, Show, Typeable, Data)
75
76
77 type ListItem = [Either ListElement InlineElement]
78
79
80 data Definition
81     = Definition {
82         defTerm :: ![InlineElement]
83       , defDesc :: ![InlineElement]
84       }
85     deriving (Eq, Show, Typeable, Data)
86
87
88 data CommandType
89     = InlineCommandType
90     | BlockCommandType
91     deriving (Eq, Show)
92
93
94 type Attribute = (String, String)
95
96
97 data BlockCommand
98     = BlockCommand {
99         bCmdName       :: !String
100       , bCmdAttributes :: ![Attribute]
101       , bCmdContents   :: ![BlockElement]
102       }
103     deriving (Eq, Show, Typeable, Data)
104
105
106 data InlineCommand
107     = InlineCommand {
108         iCmdName       :: !String
109       , iCmdAttributes :: ![Attribute]
110       , iCmdContents   :: ![InlineElement]
111       }
112     deriving (Eq, Show, Typeable, Data)