git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: don't use page-progression-direction in EPUB2.

Also, if page-progression-direction not specified in metadata, don't include the attribute even in EPUB3; not including it is the same as including it with the value "default", as we did before. Closes #1550.

commit60f3e777f33623bcd6b3a98573d82f6cb2d8d978 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 19 Aug 2014, 09:21 (12 years ago) parenta79d477
1 file changed+14−16
src/Text/Pandoc/Writers/EPUB.hs+14−16
src/Text/Pandoc/Writers/EPUB.hs+14−16
@@ -94,7 +94,7 @@ data EPUBMetadata = EPUBMetadata{
9494 , epubRights :: Maybe String
9595 , epubCoverImage :: Maybe String
9696 , epubStylesheet :: Maybe Stylesheet
97− , epubPageDirection :: ProgressionDirection
97+ , epubPageDirection :: Maybe ProgressionDirection
9898 } deriving Show
9999
100100data Stylesheet = StylesheetPath FilePath
@@ -123,7 +123,7 @@ data Title = Title{
123123 , titleType :: Maybe String
124124 } deriving Show
125125
126−data ProgressionDirection = LTR | RTL | Default deriving Show
126+data ProgressionDirection = LTR | RTL deriving Show
127127
128128dcName :: String -> QName
129129dcName n = QName n Nothing (Just "dc")
@@ -322,14 +322,11 @@ metadataFromMeta opts meta = EPUBMetadata{
322322 stylesheet = (StylesheetContents <$> writerEpubStylesheet opts) `mplus`
323323 ((StylesheetPath . metaValueToString) <$>
324324 lookupMeta "stylesheet" meta)
325− pageDirection = maybe Default stringToPageDirection
326− (lookupMeta "page-progression-direction" meta)
327− stringToPageDirection (metaValueToString -> s) =
328− case s of
329− "ltr" -> LTR
330− "rtl" -> RTL
331− _ -> Default
332−
325+ pageDirection = case map toLower . metaValueToString <$>
326+ lookupMeta "page-progression-direction" meta of
327+ Just "ltr" -> Just LTR
328+ Just "rtl" -> Just RTL
329+ _ -> Nothing
333330
334331-- | Produce an EPUB file from a Pandoc document.
335332writeEPUB :: WriterOptions -- ^ Writer options
@@ -394,11 +391,13 @@ writeEPUB opts doc@(Pandoc meta _) = do
394391 let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f
395392 fontEntries <- mapM mkFontEntry $ writerEpubFonts opts'
396393
397− -- set page progression direction
394+ -- set page progression direction attribution
398395 let progressionDirection = case epubPageDirection metadata of
399− LTR -> "ltr"
400− RTL -> "rtl"
401− Default -> "default"
396+ Just LTR | epub3 ->
397+ [("page-progression-direction", "ltr")]
398+ Just RTL | epub3 ->
399+ [("page-progression-direction", "rtl")]
400+ _ -> []
402401
403402 -- body pages
404403
@@ -519,8 +518,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
519518 (pictureNode x)]) ++
520519 map pictureNode picEntries ++
521520 map fontNode fontEntries
522− , unode "spine" ! [("toc","ncx")
523− ,("page-progression-direction", progressionDirection)] $
521+ , unode "spine" ! ([("toc","ncx")] ++ progressionDirection) $
524522 case epubCoverImage metadata of
525523 Nothing -> []
526524 Just _ -> [ unode "itemref" !