git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Use writerNumberFrom instead of ugly hack.
commita33828f3759e60355864f0754052f91189f6746f authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 22 Feb 2013, 19:45 (14 years ago) parent4c10699
1 file changed+1−8
src/Text/Pandoc/Writers/EPUB.hs+1−8
src/Text/Pandoc/Writers/EPUB.hs+1−8
@@ -147,9 +147,8 @@ writeEPUB opts doc@(Pandoc meta _) = do
147147
148148 let chapToEntry :: Int -> [Block] -> Entry
149149 chapToEntry num bs = mkEntry (showChapter num)
150− $ fixSectionNumbers num
151150 $ renderHtml
152− $ writeHtml opts'
151+ $ writeHtml opts'{ writerNumberFrom = num }
153152 $ case bs of
154153 (Header _ _ xs : _) -> Pandoc (Meta xs [] []) bs
155154 _ -> Pandoc (Meta [] [] []) bs
@@ -478,9 +477,3 @@ replaceRefs refTable = bottomUp replaceOneRef
478477 Just url -> Link lab (url,tit)
479478 Nothing -> x
480479 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)