aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 783aaa8fd..3971b7740 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -223,8 +223,12 @@ writeHtmlString' st opts d = do
case getField "pagetitle" context of
Just (s :: Text) | not (T.null s) -> return context
_ -> do
- let fallback = maybe "Untitled" (takeBaseName . T.unpack) $
- lookupContext "sourcefile" (writerVariables opts)
+ let fallback =
+ case lookupContext "sourcefile"
+ (writerVariables opts) of
+ Nothing -> "Untitled"
+ Just [] -> "Untitled"
+ Just (x:_) -> takeBaseName $ T.unpack x
report $ NoTitleElement fallback
return $ resetField "pagetitle" (T.pack fallback) context
return $ render Nothing $ renderTemplate tpl