From b206e941caeba9f840557694f351b5cafe4af657 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 6 Jan 2026 19:08:30 +0100 Subject: EPUB writer: don't use footnote backlinks for EPUBv3. Here we use aside elements, which are popups, and the backlinks are not needed; in some readers they cause a redundant number to appear, since the reader adds a note number. Standard practice seems to be not to use these. --- src/Text/Pandoc/Writers/HTML.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 2b4cfc5aa..3c45c2e61 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -1689,14 +1689,16 @@ blockListToNote opts ref blocks = do let kvs = [("role","doc-backlink") | html5] let backlink = Link ("",["footnote-back"],kvs) [Str ref] ("#" <> "fnref" <> ref,"") - let blocks' = - case blocks of - (Para ils : rest) -> - Para (backlink : Str "." : Space : ils) : rest - (Plain ils : rest) -> - Plain (backlink : Str "." : Space : ils) : rest - _ -> Para [backlink , Str "."] : blocks - contents <- blockListToHtml opts blocks' + let addBacklinkInlines bs + | epubv == EPUB3 = bs + | otherwise = + case bs of + (Para ils : rest) -> + Para (backlink : Str "." : Space : ils) : rest + (Plain ils : rest) -> + Plain (backlink : Str "." : Space : ils) : rest + _ -> Para [backlink , Str "."] : blocks + contents <- blockListToHtml opts (addBacklinkInlines blocks) let noteItem = (if epubv == EPUB3 then H5.aside ! customAttribute "epub:type" "footnote" ! customAttribute "role" "doc-footnote" else H.div) ! prefixedId opts ("fn" <> ref) -- cgit v1.2.3