]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter/Base.hs
Implemented sidebars
[Rakka.git] / Rakka / Wiki / Interpreter / Base.hs
1 module Rakka.Wiki.Interpreter.Base
2     ( baseInterpreters
3     )
4     where
5
6 import           Rakka.Page
7 import           Rakka.Wiki
8 import           Rakka.Wiki.Interpreter
9 import           Rakka.Wiki.Interpreter.Base.Image
10
11
12 baseInterpreters :: [Interpreter]
13 baseInterpreters = [ lineBreakInterp
14                    , spanInterp
15                    , divInterp
16                    , imageInterp
17                    , imgFrameInterp
18
19                    , pageNameInterp
20                    ]
21
22
23 lineBreakInterp :: Interpreter
24 lineBreakInterp = InlineCommandInterpreter {
25                     iciName      = "br"
26                   , iciInterpret
27                       = \ _ (InlineCommand _ attrs _) -> return $ LineBreak attrs
28                   }
29
30
31 spanInterp :: Interpreter
32 spanInterp = InlineCommandInterpreter {
33                iciName      = "span"
34              , iciInterpret
35                  = \ _ (InlineCommand _ attrs contents) -> return $ Span attrs contents
36              }
37
38
39 divInterp :: Interpreter
40 divInterp = BlockCommandInterpreter {
41               bciName      = "div"
42             , bciInterpret
43                 = \ _ (BlockCommand _ attrs contents) -> return $ Div attrs contents
44             }
45
46
47 pageNameInterp :: Interpreter
48 pageNameInterp = InlineCommandInterpreter {
49                    iciName      = "pageName"
50                  , iciInterpret
51                      = \ ctx (InlineCommand _ _ _) -> case ctxPage ctx of
52                                                         Nothing   -> return $ Text "(None)"
53                                                         Just page -> return $ Text $ pageName page
54                  }