git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Avoid duplicate notes when headings contain notes.

This arose because the headings are copied into the metadata "title" field, and the note gets rendered twice. We strip the note now before putting the heading in "title".

commitba6a26b25871a3912556f1a17330d2363b3f3db5 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 6 Jan 2014, 12:12 (13 years ago) parent447a1bb
1 file changed+7−1
src/Text/Pandoc/Writers/EPUB.hs+7−1
src/Text/Pandoc/Writers/EPUB.hs+7−1
@@ -397,6 +397,10 @@ writeEPUB opts doc@(Pandoc meta _) = do
397397
398398 let chapters = evalState (toChapters blocks'') []
399399
400+ let removeNote :: Inline -> Inline
401+ removeNote (Note _) = Str ""
402+ removeNote x = x
403+
400404 let chapToEntry :: Int -> Chapter -> Entry
401405 chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num)
402406 $ renderHtml
@@ -404,7 +408,9 @@ writeEPUB opts doc@(Pandoc meta _) = do
404408 fromMaybe [] mbnum }
405409 $ case bs of
406410 (Header _ _ xs : _) ->
407− Pandoc (setMeta "title" (fromList xs) nullMeta) bs
411+ -- remove notes or we get doubled footnotes
412+ Pandoc (setMeta "title" (walk removeNote $ fromList xs)
413+ nullMeta) bs
408414 _ ->
409415 Pandoc nullMeta bs
410416