aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-04 11:14:10 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-04 11:14:41 +0100
commit69b3a369cacdae089d78dfb2e78287176f81a111 (patch)
tree7b1457a50dcc8ddb7defd3c4758992a08274c030 /src/Text/Pandoc/Writers
parent87764b1c46b68de556698bad797fd46dedd4dc96 (diff)
downloadpandoc-69b3a369cacdae089d78dfb2e78287176f81a111.tar.gz
HTML writer: issue warning if no title specified and template used.
See #3473.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 2afd84598..332536492 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -186,18 +186,25 @@ 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
+ defField "body" (renderHtml body) context'
writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html
writeHtml' st opts d = do
- (body, context) <- evalStateT (pandocToHtml opts d) st
- return $ case writerTemplate opts of
- Nothing -> body
- Just tpl -> renderTemplate' tpl $
- defField "body" (renderHtml body) context
+ case writerTemplate opts of
+ Just _ -> preEscapedString <$> writeHtmlString' st opts d
+ Nothing -> do
+ (body, _) <- evalStateT (pandocToHtml opts d) st
+ return body
-- result is (title, authors, date, toc, body, new variables)
pandocToHtml :: PandocMonad m
@@ -267,7 +274,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
maybe id (defField "toc" . renderHtml) toc $
defField "author-meta" authsMeta $
maybe id (defField "date-meta") (normalizeDate dateMeta) $
- defField "pagetitle" (stringifyHTML $ docTitle meta) $
+ defField "pagetitle" (stringifyHTML (docTitle meta)) $
defField "idprefix" (writerIdentifierPrefix opts) $
-- these should maybe be set in pandoc.hs
defField "slidy-url"