diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-10-08 09:22:46 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-10-09 11:01:33 -0700 |
commit | aceee9ca48484c300ac3519fb7991e3d22768312 (patch) | |
tree | 5beaccc4860fd5a9525514d2fe9e737e42703f73 /src/Text/Pandoc/Writers/HTML.hs | |
parent | 1b10b5cea947cd6567c33466006c4216fde9f107 (diff) | |
download | pandoc-aceee9ca48484c300ac3519fb7991e3d22768312.tar.gz |
Options.WriterOptions: Change type of writerVariables to Context Text.
This will allow structured values.
[API change]
Diffstat (limited to 'src/Text/Pandoc/Writers/HTML.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index c74d677e0..d7a7e19ea 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -39,6 +39,7 @@ import Data.List.Split (splitWhen) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Lazy as TL +import Text.DocTemplates (FromContext(lookupContext)) import Network.HTTP (urlEncode) import Network.URI (URI (..), parseURIReference) import Numeric (showHex) @@ -220,8 +221,8 @@ 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 $ - lookup "sourcefile" (writerVariables opts) + let fallback = maybe "Untitled" (takeBaseName . T.unpack) $ + lookupContext "sourcefile" (writerVariables opts) report $ NoTitleElement fallback return $ resetField "pagetitle" (T.pack fallback) context return $ renderTemplate tpl @@ -286,11 +287,13 @@ pandocToHtml opts (Pandoc meta blocks) = do H.link ! A.rel "stylesheet" ! A.href (toValue $ url ++ "katex.min.css") - _ -> case lookup "mathml-script" (writerVariables opts) of + _ -> case lookupContext "mathml-script" + (writerVariables opts) of Just s | not (stHtml5 st) -> H.script ! A.type_ "text/javascript" $ preEscapedString - ("/*<![CDATA[*/\n" ++ s ++ "/*]]>*/\n") + ("/*<![CDATA[*/\n" ++ T.unpack s ++ + "/*]]>*/\n") | otherwise -> mempty Nothing -> mempty let context = (if stHighlighting st |