From ba6a26b25871a3912556f1a17330d2363b3f3db5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 6 Jan 2014 12:12:21 -0800 Subject: 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". --- src/Text/Pandoc/Writers/EPUB.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 4daa9609e..d2dd7da2e 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -397,6 +397,10 @@ writeEPUB opts doc@(Pandoc meta _) = do let chapters = evalState (toChapters blocks'') [] + let removeNote :: Inline -> Inline + removeNote (Note _) = Str "" + removeNote x = x + let chapToEntry :: Int -> Chapter -> Entry chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num) $ renderHtml @@ -404,7 +408,9 @@ writeEPUB opts doc@(Pandoc meta _) = do fromMaybe [] mbnum } $ case bs of (Header _ _ xs : _) -> - Pandoc (setMeta "title" (fromList xs) nullMeta) bs + -- remove notes or we get doubled footnotes + Pandoc (setMeta "title" (walk removeNote $ fromList xs) + nullMeta) bs _ -> Pandoc nullMeta bs -- cgit v1.2.3