X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter%2FBase.hs;h=fa225e6b27144a5a253852bb66faacaf36401dd8;hb=dcfffa578c5dd6647a5be7d2074488a520dfcf2d;hp=437705dbdecbdfe7305acd7393d0d421ca104500;hpb=7c3065043cdfbd96539a9bf6bff9b1d4281c0b2a;p=Rakka.git diff --git a/Rakka/Wiki/Interpreter/Base.hs b/Rakka/Wiki/Interpreter/Base.hs index 437705d..fa225e6 100644 --- a/Rakka/Wiki/Interpreter/Base.hs +++ b/Rakka/Wiki/Interpreter/Base.hs @@ -3,6 +3,7 @@ module Rakka.Wiki.Interpreter.Base ) where +import Rakka.Page import Rakka.Wiki import Rakka.Wiki.Interpreter import Rakka.Wiki.Interpreter.Base.Image @@ -14,22 +15,40 @@ baseInterpreters = [ lineBreakInterp , divInterp , imageInterp , imgFrameInterp + + , 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 = pureInlineInterp "span" interpret - where - interpret (InlineCommand _ attrs contents) _ = Span attrs contents +spanInterp = InlineCommandInterpreter { + iciName = "span" + , iciInterpret + = \ _ (InlineCommand _ attrs contents) -> return $ Span attrs contents + } divInterp :: Interpreter -divInterp = pureBlockInterp "div" interpret - where - interpret (BlockCommand _ attrs contents) _ = Div attrs contents \ No newline at end of file +divInterp = BlockCommandInterpreter { + bciName = "div" + , bciInterpret + = \ _ (BlockCommand _ attrs contents) -> return $ Div attrs contents + } + + +pageNameInterp :: Interpreter +pageNameInterp = InlineCommandInterpreter { + iciName = "pageName" + , iciInterpret + = \ ctx (InlineCommand _ _ _) -> case ctxPage ctx of + Nothing -> return $ Text "(None)" + Just page -> return $ Text $ pageName page + } \ No newline at end of file