Rakka.Page
Rakka.Storage
Rakka.SystemConfig
+ Rakka.Utils
Rakka.Wiki
Rakka.Wiki.Interpreter
Other-Modules:
Rakka.Storage.DefaultPage
- Rakka.Utils
Data-Files:
+ defaultpages/Help/SampleImage/Large
+ defaultpages/Help/SampleImage/Small
defaultPages/Help/Syntax
defaultPages/MainPage
defaultPages/StyleSheet/Default
rakka
Main-Is:
Main.hs
+Other-Modules:
+ Rakka.Environment
+ Rakka.Resource
+ Rakka.Resource.Index
+ Rakka.Resource.Object
+ Rakka.Resource.Render
+ Rakka.Wiki.Interpreter.Base
+ Rakka.Wiki.Interpreter.Base.Image
+ Rakka.Wiki.Engine
+ Rakka.Wiki.Formatter
+ Rakka.Wiki.Parser
Extensions:
Arrows
GHC-Options:
Executable:
RakkaUnitTest
Main-Is:
- tests/RakkaUnitTest.hs
+ RakkaUnitTest.hs
Hs-Source-Dirs:
tests
+Other-Modules:
+ WikiParserTest
\ No newline at end of file
interpretCommands _ _ _ [] = return []
interpretCommands env table page blocks = mapM interpBlock blocks
where
+ ctx :: InterpreterContext
+ ctx = InterpreterContext {
+ ctxPage = page
+ , ctxTree = blocks
+ , ctxStorage = envStorage env
+ , ctxSysConf = envSysConf env
+ }
+
interpBlock :: BlockElement -> IO BlockElement
interpBlock (List list) = interpList list >>= return . List
interpBlock (DefinitionList defs) = mapM interpDefinition defs >>= return . DefinitionList
-> fail ("no such interpreter: " ++ bCmdName cmd)
Just interp
- -> bciInterpret interp cmd page (envStorage env) (envSysConf env)
+ -> bciInterpret interp ctx cmd
>>=
interpBlock
-> fail ("no such interpreter: " ++ iCmdName cmd)
Just interp
- -> iciInterpret interp cmd page (envStorage env) (envSysConf env)
+ -> iciInterpret interp ctx cmd
>>=
interpInline
module Rakka.Wiki.Interpreter
( Interpreter(..)
+ , InterpreterContext(..)
, commandName -- private
, commandType -- private
-
- , pureInlineInterp
- , pureBlockInterp
)
where
data Interpreter
= InlineCommandInterpreter {
iciName :: String
- , iciInterpret :: InlineCommand
- -> Maybe Page
- -> Storage
- -> SystemConfig
- -> IO InlineElement
+ , iciInterpret :: InterpreterContext -> InlineCommand -> IO InlineElement
}
| BlockCommandInterpreter {
bciName :: String
- , bciInterpret :: BlockCommand
- -> Maybe Page
- -> Storage
- -> SystemConfig
- -> IO BlockElement
+ , bciInterpret :: InterpreterContext -> BlockCommand -> IO BlockElement
+ }
+
+
+data InterpreterContext
+ = InterpreterContext {
+ ctxPage :: Maybe Page
+ , ctxTree :: WikiPage
+ , ctxStorage :: Storage
+ , ctxSysConf :: SystemConfig
}
commandType :: Interpreter -> CommandType
commandType (InlineCommandInterpreter _ _) = InlineCommandType
commandType (BlockCommandInterpreter _ _) = BlockCommandType
-
-
-pureInlineInterp :: String
- -> (InlineCommand -> Maybe Page -> InlineElement)
- -> Interpreter
-pureInlineInterp name f
- = InlineCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page
-
-
-pureBlockInterp :: String
- -> (BlockCommand -> Maybe Page -> BlockElement)
- -> Interpreter
-pureBlockInterp name f
- = BlockCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page
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
+ }
= InlineCommandInterpreter {
iciName = "img"
, iciInterpret
- = \ (InlineCommand _ attrs inside) _ _ sysConf ->
- do BaseURI baseURI <- getSysConf sysConf (BaseURI undefined)
+ = \ ctx (InlineCommand _ attrs inside) ->
+ do BaseURI baseURI <- getSysConf (ctxSysConf ctx) (BaseURI undefined)
let pageName = lookup "src" attrs
when (pageName == Nothing)
= BlockCommandInterpreter {
bciName = "imgframe"
, bciInterpret
- = \ (BlockCommand _ attrs inside) _ _ sysConf ->
- do BaseURI baseURI <- getSysConf sysConf (BaseURI undefined)
+ = \ ctx (BlockCommand _ attrs inside) ->
+ do BaseURI baseURI <- getSysConf (ctxSysConf ctx) (BaseURI undefined)
let pageName = lookup "src" attrs
when (pageName == Nothing)
padding: 5px;
border-color: #cccccc;
- border-width: 2px;
- border-style: dotted;
+ border-width: 1px;
+ border-style: solid;
}
.imageFrame p {