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