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