HTML writer: issue warning if no title specified and template used.
See #3473.
This commit is contained in:
parent
87764b1c46
commit
69b3a369ca
3 changed files with 16 additions and 9 deletions
|
@ -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"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title></title>
|
||||
<title>Untitled</title>
|
||||
<style type="text/css">code{white-space: pre;}</style>
|
||||
<style type="text/css">
|
||||
div.sourceCode { overflow-x: auto; }
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title></title>
|
||||
<title>Untitled</title>
|
||||
<style type="text/css">code{white-space: pre;}</style>
|
||||
<style type="text/css">
|
||||
div.sourceCode { overflow-x: auto; }
|
||||
|
|
Loading…
Add table
Reference in a new issue