aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-04 14:50:48 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-04 14:50:48 +0100
commit739bf78c376320d19a525b7b0ec5f8e13d32bb4c (patch)
tree2e437270394d4b2f4924e898b43e271ec180f436
parentaa5ae5ff0f19a3ad1739fe4afa0b26f05a5966b4 (diff)
downloadpandoc-739bf78c376320d19a525b7b0ec5f8e13d32bb4c.tar.gz
HTML writer: only issue warning for missing title if --standalone.
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 1796b6481..e904b5fb7 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -189,17 +189,19 @@ writeHtmlString' :: PandocMonad m
=> WriterState -> WriterOptions -> Pandoc -> m String
writeHtmlString' st opts d = do
(body, context) <- evalStateT (pandocToHtml opts d) st
- -- check for empty pagetitle
- context' <-
- case getField "pagetitle" context of
- Just (s :: String) | not (null s) -> return context
- _ -> do
- report $ NoTitleElement "Untitled"
- return $ resetField "pagetitle" ("Untitled" :: String) context
- return $ case writerTemplate opts of
- Nothing -> renderHtml body
- Just tpl -> renderTemplate' tpl $
- defField "body" (renderHtml body) context'
+ case writerTemplate opts of
+ Nothing -> return $ renderHtml body
+ Just tpl -> do
+ -- check for empty pagetitle
+ context' <-
+ case getField "pagetitle" context of
+ Just (s :: String) | not (null s) -> return context
+ _ -> do
+ report $ NoTitleElement "Untitled"
+ return $ resetField "pagetitle" ("Untitled" :: String)
+ context
+ return $ renderTemplate' tpl $
+ defField "body" (renderHtml body) context'
writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html
writeHtml' st opts d = do