]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki.hs
merge branch origin/master
[Rakka.git] / Rakka / Wiki.hs
1 {-# LANGUAGE
2     UnicodeSyntax
3   #-}
4 module Rakka.Wiki
5     ( WikiPage
6
7     , Element(..)
8     , Attribute
9
10     , BlockElement(..)
11     , InlineElement(..)
12
13     , Definition(..)
14
15     , ListType(..)
16     , ListItem
17
18     , CommandType(..)
19     , BlockCommand(..)
20     , InlineCommand(..)
21     )
22     where
23 import Data.CaseInsensitive (CI)
24 import Data.Text (Text)
25 import Network.URI
26 import Rakka.Page
27
28 type WikiPage = [BlockElement]
29
30 data Element
31     = Block  !BlockElement
32     | Inline !InlineElement
33     deriving (Eq, Show)
34
35 type Attribute = (CI Text, Text)
36
37 data BlockElement
38     = Heading {
39         headingLevel ∷ !Int
40       , headingText  ∷ !Text
41       }
42     | HorizontalLine
43     | List {
44         listType  ∷ !ListType
45       , listItems ∷ ![ListItem]
46       }
47     | DefinitionList ![Definition]
48     | Preformatted   ![InlineElement]
49     | Paragraph      ![InlineElement]
50     | Div            ![Attribute] ![Element]
51     | EmptyBlock
52     | BlockCmd       !BlockCommand
53     deriving (Eq, Show)
54
55 data InlineElement
56     = Text   !Text
57     | Italic ![InlineElement]
58     | Bold   ![InlineElement]
59     | ObjectLink {
60         objLinkPage ∷ !PageName
61       , objLinkText ∷ !(Maybe Text)
62       }
63     | PageLink {
64         linkPage     ∷ !(Maybe PageName)
65       , linkFragment ∷ !(Maybe Text)
66       , linkText     ∷ !(Maybe Text)
67       }
68     | ExternalLink {
69         extLinkURI  ∷ !URI
70       , extLinkText ∷ !(Maybe Text)
71       }
72     | LineBreak ![Attribute]
73     | Span      ![Attribute] ![InlineElement]
74     | Image {
75         imgSource ∷ !(Either URI PageName)
76       , imgAlt    ∷ !(Maybe Text)
77       }
78     | Anchor    ![Attribute] ![InlineElement]
79     | Input     ![Attribute]
80     | EmptyInline
81     | InlineCmd !InlineCommand
82     deriving (Eq, Show)
83
84 data ListType
85     = Bullet
86     | Numbered
87     deriving (Eq, Show)
88
89 type ListItem = [Element]
90
91 data Definition
92     = Definition {
93         defTerm ∷ ![InlineElement]
94       , defDesc ∷ ![InlineElement]
95       }
96     deriving (Eq, Show)
97
98 data CommandType
99     = InlineCommandType
100     | BlockCommandType
101     deriving (Eq, Show)
102
103 data BlockCommand
104     = BlockCommand {
105         bCmdName       ∷ !Text
106       , bCmdAttributes ∷ ![Attribute]
107       , bCmdContents   ∷ ![BlockElement]
108       }
109     deriving (Eq, Show)
110
111 data InlineCommand
112     = InlineCommand {
113         iCmdName       :: !Text
114       , iCmdAttributes :: ![Attribute]
115       , iCmdContents   :: ![InlineElement]
116       }
117     deriving (Eq, Show)