EPUB writer: set epub:type on body element intelligently.
epub:type of first section epub:type of body -------------------------- ------------------ prologue frontmatter abstract frontmatter acknowledgments frontmatter copyright-page frontmatter dedication frontmatter foreword frontmatter halftitle, frontmatter introduction frontmatter preface frontmatter seriespage frontmatter titlepage frontmatter afterword backmatter appendix backmatter colophon backmatter conclusion backmatter epigraph backmatter Otherwise body will have epub:type 'bodymatter'. This only affects epub3. See http://www.idpf.org/epub/profiles/edu/structure/#h.l0bzsloklt10 Closes #4823.
This commit is contained in:
parent
dac85d683f
commit
7318bc91ce
2 changed files with 23 additions and 7 deletions
|
@ -26,7 +26,7 @@ $for(header-includes)$
|
||||||
$header-includes$
|
$header-includes$
|
||||||
$endfor$
|
$endfor$
|
||||||
</head>
|
</head>
|
||||||
<body$if(coverpage)$ id="cover"$endif$>
|
<body$if(coverpage)$ id="cover"$endif$$if(body-type)$ epub:type="$body-type$"$endif$>
|
||||||
$if(titlepage)$
|
$if(titlepage)$
|
||||||
<section epub:type="titlepage">
|
<section epub:type="titlepage">
|
||||||
$for(title)$
|
$for(title)$
|
||||||
|
|
|
@ -461,6 +461,7 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
|
||||||
-- title page
|
-- title page
|
||||||
tpContent <- lift $ writeHtml opts'{
|
tpContent <- lift $ writeHtml opts'{
|
||||||
writerVariables = ("titlepage","true"):
|
writerVariables = ("titlepage","true"):
|
||||||
|
("body-type", "frontmatter"):
|
||||||
("pagetitle", escapeStringForXML plainTitle):
|
("pagetitle", escapeStringForXML plainTitle):
|
||||||
cssvars True ++ vars }
|
cssvars True ++ vars }
|
||||||
(Pandoc meta [])
|
(Pandoc meta [])
|
||||||
|
@ -565,13 +566,28 @@ pandocToEPUB version opts doc@(Pandoc meta _) = do
|
||||||
let chapToEntry num (Chapter mbnum bs) =
|
let chapToEntry num (Chapter mbnum bs) =
|
||||||
mkEntry ("text/" ++ showChapter num) =<<
|
mkEntry ("text/" ++ showChapter num) =<<
|
||||||
writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum
|
writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum
|
||||||
, writerVariables = cssvars True ++ vars }
|
, writerVariables = ("body-type", bodyType) :
|
||||||
(case bs of
|
cssvars True ++ vars } pdoc
|
||||||
(Header _ _ xs : _) ->
|
where (pdoc, bodyType) =
|
||||||
|
case bs of
|
||||||
|
(Header _ (_,_,kvs) xs : _) ->
|
||||||
-- remove notes or we get doubled footnotes
|
-- remove notes or we get doubled footnotes
|
||||||
Pandoc (setMeta "title" (walk removeNote $ fromList xs)
|
(Pandoc (setMeta "title"
|
||||||
nullMeta) bs
|
(walk removeNote $ fromList xs) nullMeta) bs,
|
||||||
_ -> Pandoc nullMeta bs)
|
case lookup "epub:type" kvs of
|
||||||
|
Nothing -> "bodymatter"
|
||||||
|
Just x
|
||||||
|
| x `elem` frontMatterTypes -> "frontmatter"
|
||||||
|
| x `elem` backMatterTypes -> "backmatter"
|
||||||
|
| otherwise -> "bodymatter")
|
||||||
|
_ -> (Pandoc nullMeta bs, "bodymatter")
|
||||||
|
frontMatterTypes = ["prologue", "abstract", "acknowledgments",
|
||||||
|
"copyright-page", "dedication",
|
||||||
|
"foreword", "halftitle",
|
||||||
|
"introduction", "preface",
|
||||||
|
"seriespage", "titlepage"]
|
||||||
|
backMatterTypes = ["afterword", "appendix", "colophon",
|
||||||
|
"conclusion", "epigraph"]
|
||||||
|
|
||||||
chapterEntries <- zipWithM chapToEntry [1..] chapters
|
chapterEntries <- zipWithM chapToEntry [1..] chapters
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue