@@ -461,6 +461,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
461 -- title page
461 -- title page
462 tpContent <- lift $ writeHtml opts'{
462 tpContent <- lift $ writeHtml opts'{
463 writerVariables = ("titlepage","true"):
463 writerVariables = ("titlepage","true"):
464+ ("body-type", "frontmatter"):
464 ("pagetitle", escapeStringForXML plainTitle):
465 ("pagetitle", escapeStringForXML plainTitle):
465 cssvars True ++ vars }
466 cssvars True ++ vars }
466 (Pandoc meta [])
467 (Pandoc meta [])
@@ -565,13 +566,28 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
565 let chapToEntry num (Chapter mbnum bs) =
566 let chapToEntry num (Chapter mbnum bs) =
566 mkEntry ("text/" ++ showChapter num) =<<
567 mkEntry ("text/" ++ showChapter num) =<<
567 writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum
568 writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum
569+ , writerVariables = ("body-type", bodyType) :
568− , writerVariables = cssvars True ++ vars }
570+ cssvars True ++ vars } pdoc
571+ where (pdoc, bodyType) =
569− (case bs of
572+ case bs of
570− (Header _ _ xs : _) ->
573+ (Header _ (_,_,kvs) xs : _) ->
571 -- remove notes or we get doubled footnotes
574 -- remove notes or we get doubled footnotes
575+ (Pandoc (setMeta "title"
572− Pandoc (setMeta "title" (walk removeNote $ fromList xs)
576+ (walk removeNote $ fromList xs) nullMeta) bs,
573− nullMeta) bs
577+ case lookup "epub:type" kvs of
578+ Nothing -> "bodymatter"
580+ | x `elem` frontMatterTypes -> "frontmatter"
581+ | x `elem` backMatterTypes -> "backmatter"
582+ | otherwise -> "bodymatter")
574− _ -> Pandoc nullMeta bs)
583+ _ -> (Pandoc nullMeta bs, "bodymatter")
584+ frontMatterTypes = ["prologue", "abstract", "acknowledgments",
585+ "copyright-page", "dedication",
586+ "foreword", "halftitle",
587+ "introduction", "preface",
588+ "seriespage", "titlepage"]
589+ backMatterTypes = ["afterword", "appendix", "colophon",
590+ "conclusion", "epigraph"]
576 chapterEntries <- zipWithM chapToEntry [1..] chapters
592 chapterEntries <- zipWithM chapToEntry [1..] chapters