interpretCommands env table page blocks = mapM interpBlock blocks
where
interpBlock :: BlockElement -> IO BlockElement
- interpBlock (List list) = interpList list >>= return . List
+ interpBlock (List list) = interpList list >>= return . List
interpBlock (DefinitionList defs) = mapM interpDefinition defs >>= return . DefinitionList
- interpBlock (Preformatted xs ) = mapM interpInline xs >>= return . Preformatted
- interpBlock (Paragraph xs ) = mapM interpInline xs >>= return . Paragraph
+ interpBlock (Preformatted xs) = mapM interpInline xs >>= return . Preformatted
+ interpBlock (Paragraph xs) = mapM interpInline xs >>= return . Paragraph
+ interpBlock (Div attrs xs) = mapM interpBlock xs >>= return . Div attrs
+ interpBlock (BlockCmd cmd) = interpBlockCmd cmd
interpBlock others = return others
interpList :: ListElement -> IO ListElement
desc <- mapM interpInline (defDesc def)
return $ def { defTerm = term, defDesc = desc }
+ interpBlockCmd :: BlockCommand -> IO BlockElement
+ interpBlockCmd cmd
+ = case M.lookup (bCmdName cmd) table of
+ Nothing
+ -> fail ("no such interpreter: " ++ bCmdName cmd)
+
+ Just interp
+ -> bciInterpret interp cmd page (envStorage env) (envSysConf env)
+ >>=
+ interpBlock
+
interpInline :: InlineElement -> IO InlineElement
- interpInline (Italic xs ) = mapM interpInline xs >>= return . Italic
- interpInline (Bold xs ) = mapM interpInline xs >>= return . Bold
+ interpInline (Italic xs) = mapM interpInline xs >>= return . Italic
+ interpInline (Bold xs ) = mapM interpInline xs >>= return . Bold
+ interpInline (Span attrs xs) = mapM interpInline xs >>= return . Span attrs
interpInline (InlineCmd cmd) = interpInlineCmd cmd
interpInline others = return others