From 421ae44cdfb5d1049246d61cabf647d6056eb554 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 25 Nov 2019 17:50:27 -0800 Subject: EPUB writer: Fix regression with `--css option. Closes #5937. --- src/Text/Pandoc/Writers/EPUB.hs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4a1c27ce6..b3cf79ba2 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -357,8 +357,12 @@ metadataFromMeta opts meta = EPUBMetadata{ `mplus` (metaValueToString <$> lookupMeta "cover-image" meta) mCss = lookupMeta "css" meta <|> lookupMeta "stylesheet" meta stylesheets = fromMaybe [] (metaValueToPaths <$> mCss) ++ - maybe [] (\t -> [TS.unpack t]) - (lookupContext "css" (writerVariables opts)) + case lookupContext "css" (writerVariables opts) of + Just xs -> map TS.unpack xs + Nothing -> + case lookupContext "css" (writerVariables opts) of + Just x -> [TS.unpack x] + Nothing -> [] pageDirection = case map toLower . metaValueToString <$> lookupMeta "page-progression-direction" meta of Just "ltr" -> Just LTR @@ -440,13 +444,13 @@ pandocToEPUB version opts doc = do M.insert "lang" (toVal' $ epubLanguage metadata) $ unContext $ writerVariables opts - let cssvars useprefix = Context $ M.fromList $ map - (\e -> ("css", toVal' $ - (if useprefix - then "../" - else "") - ++ makeRelative epubSubdir (eRelativePath e))) - stylesheetEntries + let cssvars useprefix = Context $ M.insert "css" + (ListVal $ map + (\e -> toVal' $ + (if useprefix then "../" else "") <> + makeRelative epubSubdir (eRelativePath e)) + stylesheetEntries) + mempty let opts' = opts{ writerEmailObfuscation = NoObfuscation , writerSectionDivs = True -- cgit v1.2.3