EPUB writer: Insert "svg" property as needed in opf (EPUB 3).

This commit is contained in:
John MacFarlane 2013-11-30 20:20:18 -08:00
parent a7067ab22b
commit 0e158d8d8d

View file

@ -401,15 +401,21 @@ writeEPUB opts doc@(Pandoc meta _) = do
let chapterEntries = zipWith chapToEntry [1..] chapters let chapterEntries = zipWith chapToEntry [1..] chapters
-- incredibly inefficient (TODO): -- incredibly inefficient (TODO):
let containsMathML ent = "<math" `isInfixOf` (B8.unpack $ fromEntry ent) let containsMathML ent = epub3 &&
"<math" `isInfixOf` (B8.unpack $ fromEntry ent)
let containsSVG ent = epub3 &&
"<svg" `isInfixOf` (B8.unpack $ fromEntry ent)
let props ent = ["mathml" | containsMathML ent] ++ ["svg" | containsSVG ent]
-- contents.opf -- contents.opf
let chapterNode ent = unode "item" ! let chapterNode ent = unode "item" !
([("id", takeBaseName $ eRelativePath ent), ([("id", takeBaseName $ eRelativePath ent),
("href", eRelativePath ent), ("href", eRelativePath ent),
("media-type", "application/xhtml+xml")] ("media-type", "application/xhtml+xml")]
++ [("properties","mathml") | epub3 && ++ case props ent of
containsMathML ent]) $ () [] -> []
xs -> [("properties", unwords xs)])
$ ()
let chapterRefNode ent = unode "itemref" ! let chapterRefNode ent = unode "itemref" !
[("idref", takeBaseName $ eRelativePath ent)] $ () [("idref", takeBaseName $ eRelativePath ent)] $ ()
let pictureNode ent = unode "item" ! let pictureNode ent = unode "item" !