@@ -189,17 +189,19 @@ writeHtmlString' :: PandocMonad m
189189 => WriterState -> WriterOptions -> Pandoc -> m String
190190writeHtmlString' st opts d = do
191191 (body, context) <- evalStateT (pandocToHtml opts d) st
192− -- check for empty pagetitle
193− context' <-
194− case getField "pagetitle" context of
195− Just (s :: String) | not (null s) -> return context
196− _ -> do
197− report $ NoTitleElement "Untitled"
198− return $ resetField "pagetitle" ("Untitled" :: String) context
199− return $ case writerTemplate opts of
200− Nothing -> renderHtml body
201− Just tpl -> renderTemplate' tpl $
202− defField "body" (renderHtml body) context'
192+ case writerTemplate opts of
193+ Nothing -> return $ renderHtml body
194+ Just tpl -> do
195+ -- check for empty pagetitle
196+ context' <-
197+ case getField "pagetitle" context of
198+ Just (s :: String) | not (null s) -> return context
199+ _ -> do
200+ report $ NoTitleElement "Untitled"
201+ return $ resetField "pagetitle" ("Untitled" :: String)
202+ context
203+ return $ renderTemplate' tpl $
204+ defField "body" (renderHtml body) context'
203205
204206writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html
205207writeHtml' st opts d = do