]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Wiki/Interpreter/Base.hs
Farewell the dream of plug-in system... It's way too hard to implement nicely. Many...
[Rakka.git] / Rakka / Wiki / Interpreter / Base.hs
index bd11029034d60b45184234e10cd5759263742d19..0070a837c376df6838bd2796d894cdaef62ccfa6 100644 (file)
@@ -1,17 +1,47 @@
 module Rakka.Wiki.Interpreter.Base
-    ( baseInterpreters
+    ( interpreters
     )
     where
 
-import           Rakka.Wiki.Interpreter
 import           Rakka.Wiki
+import           Rakka.Wiki.Interpreter
 
 
-baseInterpreters :: [Interpreter]
-baseInterpreters = [ lineBreakInterp ]
+interpreters :: [Interpreter]
+interpreters = [ lineBreakInterp
+               , spanInterp
+               , divInterp
+               , pageNameInterp
+               ]
 
 
 lineBreakInterp :: Interpreter
-lineBreakInterp = pureInlineInterp "br" interpret
-    where
-      interpret (InlineCommand _ attrs _) _ = LineBreak attrs
+lineBreakInterp = InlineCommandInterpreter {
+                    iciName      = "br"
+                  , iciInterpret
+                      = \ _ (InlineCommand _ attrs _) -> return $ LineBreak attrs
+                  }
+
+
+spanInterp :: Interpreter
+spanInterp = InlineCommandInterpreter {
+               iciName      = "span"
+             , iciInterpret
+                 = \ _ (InlineCommand _ attrs contents) -> return $ Span attrs contents
+             }
+
+
+divInterp :: Interpreter
+divInterp = BlockCommandInterpreter {
+              bciName      = "div"
+            , bciInterpret
+                = \ _ (BlockCommand _ attrs contents) -> return $ Div attrs contents
+            }
+
+
+pageNameInterp :: Interpreter
+pageNameInterp = InlineCommandInterpreter {
+                   iciName      = "pageName"
+                 , iciInterpret
+                     = \ ctx _ -> return $ Text (ctxPageName ctx)
+                 }