]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter.hs
Resurrection from bitrot
[Rakka.git] / Rakka / Wiki / Interpreter.hs
1 {-# LANGUAGE
2     UnicodeSyntax
3   #-}
4 module Rakka.Wiki.Interpreter
5     ( Interpreter(..)
6     , InterpreterContext(..)
7
8     , commandName -- private
9     , commandType -- private
10     )
11     where
12 import Data.Text (Text)
13 import Rakka.Page
14 import Rakka.Storage
15 import Rakka.SystemConfig
16 import Rakka.Wiki
17 import Text.XML.HXT.DOM.TypeDefs
18
19 data Interpreter
20     = InlineCommandInterpreter {
21         iciName      ∷ !Text
22       , iciInterpret ∷ !(InterpreterContext → InlineCommand → IO InlineElement)
23       }
24     | BlockCommandInterpreter {
25         bciName      ∷ !Text
26       , bciInterpret ∷ !(InterpreterContext → BlockCommand → IO BlockElement)
27       }
28
29
30 data InterpreterContext
31     = InterpreterContext {
32         ctxPageName   :: !(Maybe PageName)
33       , ctxMainPage   :: !(Maybe XmlTree)
34       , ctxMainWiki   :: !(Maybe WikiPage)
35       , ctxTargetWiki :: !WikiPage
36       , ctxStorage    :: !Storage
37       , ctxSysConf    :: !SystemConfig
38       }
39
40 commandName ∷ Interpreter → Text
41 commandName (InlineCommandInterpreter name _) = name
42 commandName (BlockCommandInterpreter  name _) = name
43
44 commandType ∷ Interpreter → CommandType
45 commandType (InlineCommandInterpreter _ _) = InlineCommandType
46 commandType (BlockCommandInterpreter  _ _) = BlockCommandType