git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: use metadata field `css` instead of `stylesheet`

closes #4990

commit7e6f13cf81d8233d18db68e263d01d620dcf0350 authormb21 <mb21@users.noreply.github.com> dateSun 21 Oct 2018, 13:48 (8 years ago) parent8ef995c
2 files changed+7−6
MANUAL.txt+3−3 src/Text/Pandoc/Writers/EPUB.hs+4−3
MANUAL.txt+3−3
@@ -976,8 +976,8 @@ Options affecting specific writers {.options}
976976 include multiple files. They will be included in the order specified.
977977
978978 A stylesheet is required for generating EPUB. If none is
979− provided using this option (or the `stylesheet` metadata
980− field), pandoc will look for a file `epub.css` in the
979+ provided using this option (or the deprecated `stylesheet`
980+ metadata field), pandoc will look for a file `epub.css` in the
981981 user data directory (see `--data-dir`). If it is not
982982 found there, sensible defaults will be used.
983983
@@ -4613,7 +4613,7 @@ The following fields are recognized:
46134613`cover-image`
46144614 ~ A string value (path to cover image).
46154615
4616−`stylesheet`
4616+`css` (or legacy: `stylesheet`)
46174617 ~ A string value (path to CSS stylesheet).
46184618
46194619`page-progression-direction`
src/Text/Pandoc/Writers/EPUB.hs+4−3
@@ -36,6 +36,7 @@ module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where
3636import Prelude
3737import Codec.Archive.Zip (Entry, addEntryToArchive, eRelativePath, emptyArchive,
3838 fromArchive, fromEntry, toEntry)
39+import Control.Applicative ( (<|>) )
3940import Control.Monad (mplus, unless, when, zipWithM)
4041import Control.Monad.Except (catchError, throwError)
4142import Control.Monad.State.Strict (State, StateT, evalState, evalStateT, get,
@@ -351,9 +352,9 @@ metadataFromMeta opts meta = EPUBMetadata{
351352 rights = metaValueToString <$> lookupMeta "rights" meta
352353 coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus`
353354 (metaValueToString <$> lookupMeta "cover-image" meta)
354− stylesheets = fromMaybe []
355− (metaValueToPaths <$> lookupMeta "stylesheet" meta) ++
356− [f | ("css",f) <- writerVariables opts]
355+ mCss = lookupMeta "css" meta <|> lookupMeta "stylesheet" meta
356+ stylesheets = fromMaybe [] (metaValueToPaths <$> mCss) ++
357+ [f | ("css",f) <- writerVariables opts]
357358 pageDirection = case map toLower . metaValueToString <$>
358359 lookupMeta "page-progression-direction" meta of
359360 Just "ltr" -> Just LTR