@@ -147,6 +147,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
147147
148148 let chapToEntry :: Int -> [Block] -> Entry
149149 chapToEntry num bs = mkEntry (showChapter num)
150+ $ fixSectionNumbers num
150151 $ renderHtml
151152 $ writeHtml opts'
152153 $ case bs of
@@ -230,7 +231,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
230231
231232 let navPointNode :: (Int -> String -> String -> [Element] -> Element)
232233 -> Shared.Element -> State Int Element
233− navPointNode formatter (Sec _ nums (ident,classes,keyvals) ils children) = do
234+ navPointNode formatter (Sec _ nums (ident,_,_) ils children) = do
234235 n <- get
235236 modify (+1)
236237 let showNums :: [Int] -> String
@@ -477,3 +478,9 @@ replaceRefs refTable = bottomUp replaceOneRef
477478 Just url -> Link lab (url,tit)
478479 Nothing -> x
479480 replaceOneRef x = x
481+
482+-- This is ugly and inefficient.
483+fixSectionNumbers :: Int -> B8.ByteString -> B8.ByteString
484+fixSectionNumbers num = B8.pack . go . B8.unpack
485+ where go = substitute "<span class=\"header-section-number\">1"
486+ ("<span class=\"header-section-number\">" ++ show num)