git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: adjust internal links to identifiers...
1ce7db1John MacFarlane
src/Text/Pandoc/Writers/EPUB.hs+20
@@ -561,6 +561,16 @@ pandocToEPUB version opts doc = do
561 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
561 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
562 extractLinkURL' num (Image (ident, _, _) _ _)
562 extractLinkURL' num (Image (ident, _, _) _ _)
563 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
563 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
564+ extractLinkURL' num (RawInline fmt raw)
565+ | isHtmlFormat fmt
566+ = foldr (\tag ->
567+ case tag of
568+ TagOpen{} ->
569+ case fromAttrib "id" tag of
570+ "" -> id
571+ x -> ((x, TS.pack (showChapter num) <> "#" <> x):)
572+ _ -> id)
573+ [] (parseTags raw)
564 extractLinkURL' _ _ = []
574 extractLinkURL' _ _ = []
565
575
566 let extractLinkURL :: Int -> Block -> [(TS.Text, TS.Text)]
576 let extractLinkURL :: Int -> Block -> [(TS.Text, TS.Text)]
@@ -570,6 +580,16 @@ pandocToEPUB version opts doc = do
570 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
580 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
571 extractLinkURL num (Table (ident,_,_) _ _ _ _ _)
581 extractLinkURL num (Table (ident,_,_) _ _ _ _ _)
572 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
582 | not (TS.null ident) = [(ident, TS.pack (showChapter num) <> "#" <> ident)]
583+ extractLinkURL num (RawBlock fmt raw)
584+ | isHtmlFormat fmt
585+ = foldr (\tag ->
586+ case tag of
587+ TagOpen{} ->
588+ case fromAttrib "id" tag of
589+ "" -> id
590+ x -> ((x, TS.pack (showChapter num) <> "#" <> x):)
591+ _ -> id)
592+ [] (parseTags raw)
573 extractLinkURL num b = query (extractLinkURL' num) b
593 extractLinkURL num b = query (extractLinkURL' num) b
574
594
575 let reftable = concat $ zipWith (\(Chapter bs) num ->
595 let reftable = concat $ zipWith (\(Chapter bs) num ->