]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter.hs
Implemented the outline command
[Rakka.git] / Rakka / Wiki / Interpreter.hs
1 module Rakka.Wiki.Interpreter
2     ( Interpreter(..)
3     , InterpreterContext(..)
4
5     , commandName -- private
6     , commandType -- private
7     )
8     where
9
10 import           Rakka.Page
11 import           Rakka.Storage
12 import           Rakka.SystemConfig
13 import           Rakka.Wiki
14
15
16 data Interpreter
17     = InlineCommandInterpreter {
18         iciName      :: !String
19       , iciInterpret :: !(InterpreterContext -> InlineCommand -> IO InlineElement)
20       }
21     | BlockCommandInterpreter {
22         bciName      :: !String
23       , bciInterpret :: !(InterpreterContext -> BlockCommand -> IO BlockElement)
24       }
25
26
27 data InterpreterContext
28     = InterpreterContext {
29         ctxPageName   :: !PageName
30       , ctxMainTree   :: !(Maybe WikiPage)
31       , ctxTargetTree :: !WikiPage
32       , ctxStorage    :: !Storage
33       , ctxSysConf    :: !SystemConfig
34       }
35
36
37 commandName :: Interpreter -> String
38 commandName (InlineCommandInterpreter name _) = name
39 commandName (BlockCommandInterpreter  name _) = name
40
41
42 commandType :: Interpreter -> CommandType
43 commandType (InlineCommandInterpreter _ _) = InlineCommandType
44 commandType (BlockCommandInterpreter  _ _) = BlockCommandType