aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-01-04 11:38:18 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-01-04 11:38:18 -0800
commit1ce7db1fa67b6a9f1d354d377e3bfa548d854ee9 (patch)
tree000f43497e56a5415ead9f4b0367ae45a26cb02e
parentf04e02d8d5ff893475c129aaf69ee3f175bf8d8f (diff)
downloadpandoc-1ce7db1fa67b6a9f1d354d377e3bfa548d854ee9.tar.gz
EPUB writer: adjust internal links to identifiers...
defined in raw HTML sections after splitting into chapters. Closes #7000.
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 6222b0690..c8f5ff60d 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -561,6 +561,16 @@ pandocToEPUB version opts doc = do
| not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
extractLinkURL' num (Image (ident, _, _) _ _)
| not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
+ extractLinkURL' num (RawInline fmt raw)
+ | isHtmlFormat fmt
+ = foldr (\tag ->
+ case tag of
+ TagOpen{} ->
+ case fromAttrib "id" tag of
+ "" -> id
+ x -> ((x, TS.pack (showChapter num) <> "#" <> x):)
+ _ -> id)
+ [] (parseTags raw)
extractLinkURL' _ _ = []
let extractLinkURL :: Int -> Block -> [(TS.Text, TS.Text)]
@@ -570,6 +580,16 @@ pandocToEPUB version opts doc = do
| not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
extractLinkURL num (Table (ident,_,_) _ _ _ _ _)
| not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
+ extractLinkURL num (RawBlock fmt raw)
+ | isHtmlFormat fmt
+ = foldr (\tag ->
+ case tag of
+ TagOpen{} ->
+ case fromAttrib "id" tag of
+ "" -> id
+ x -> ((x, TS.pack (showChapter num) <> "#" <> x):)
+ _ -> id)
+ [] (parseTags raw)
extractLinkURL num b = query (extractLinkURL' num) b
let reftable = concat $ zipWith (\(Chapter bs) num ->