git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Fix regression with `--css option.

Closes #5937.

commit421ae44cdfb5d1049246d61cabf647d6056eb554 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 25 Nov 2019, 17:50 (7 years ago) parentce0a4f8
1 file changed+13−9
src/Text/Pandoc/Writers/EPUB.hs+13−9
src/Text/Pandoc/Writers/EPUB.hs+13−9
@@ -357,8 +357,12 @@ metadataFromMeta opts meta = EPUBMetadata{
357357 `mplus` (metaValueToString <$> lookupMeta "cover-image" meta)
358358 mCss = lookupMeta "css" meta <|> lookupMeta "stylesheet" meta
359359 stylesheets = fromMaybe [] (metaValueToPaths <$> mCss) ++
360− maybe [] (\t -> [TS.unpack t])
361− (lookupContext "css" (writerVariables opts))
360+ case lookupContext "css" (writerVariables opts) of
361+ Just xs -> map TS.unpack xs
362+ Nothing ->
363+ case lookupContext "css" (writerVariables opts) of
364+ Just x -> [TS.unpack x]
365+ Nothing -> []
362366 pageDirection = case map toLower . metaValueToString <$>
363367 lookupMeta "page-progression-direction" meta of
364368 Just "ltr" -> Just LTR
@@ -440,13 +444,13 @@ pandocToEPUB version opts doc = do
440444 M.insert "lang" (toVal' $ epubLanguage metadata)
441445 $ unContext $ writerVariables opts
442446
443− let cssvars useprefix = Context $ M.fromList $ map
444− (\e -> ("css", toVal' $
445− (if useprefix
446− then "../"
447− else "")
448− ++ makeRelative epubSubdir (eRelativePath e)))
449− stylesheetEntries
447+ let cssvars useprefix = Context $ M.insert "css"
448+ (ListVal $ map
449+ (\e -> toVal' $
450+ (if useprefix then "../" else "") <>
451+ makeRelative epubSubdir (eRelativePath e))
452+ stylesheetEntries)
453+ mempty
450454
451455 let opts' = opts{ writerEmailObfuscation = NoObfuscation
452456 , writerSectionDivs = True