EPUB writer: Minor section numbering tweaks.

* If we need to add an initial section, make it unnumbered.
* Don't add extra space before unnumbered section titles in TOC.
This commit is contained in:
John MacFarlane 2013-02-22 20:38:56 -08:00
parent 4d54c6368b
commit a7245b453c

View file

@ -126,7 +126,8 @@ writeEPUB opts doc@(Pandoc meta _) = do
let blocks' = addIdentifiers let blocks' = addIdentifiers
$ case blocks of $ case blocks of
(Header 1 _ _ : _) -> blocks (Header 1 _ _ : _) -> blocks
_ -> Header 1 ("",[],[]) (docTitle meta) : blocks _ -> Header 1 ("",["unnumbered"],[])
(docTitle meta) : blocks
let chapterHeaderLevel = writerEpubChapterLevel opts let chapterHeaderLevel = writerEpubChapterLevel opts
-- internal reference IDs change when we chunk the file, -- internal reference IDs change when we chunk the file,
@ -236,7 +237,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
let showNums :: [Int] -> String let showNums :: [Int] -> String
showNums = intercalate "." . map show showNums = intercalate "." . map show
let tit' = plainify ils let tit' = plainify ils
let tit = if writerNumberSections opts let tit = if writerNumberSections opts && not (null nums)
then showNums nums ++ " " ++ tit' then showNums nums ++ " " ++ tit'
else tit' else tit'
let src = case lookup ident reftable of let src = case lookup ident reftable of