git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1519 from mpickering/more

EPUB Normalisation and anchors for div blocks in tex

commit95d9b43b425a57575c4c147a105cbe69d78854eb authorJohn MacFarlane <jgm@berkeley.edu> dateMon 11 Aug 2014, 11:28 (12 years ago) parent6fae1361952dd0
2 files changed+8−3
src/Text/Pandoc/Readers/EPUB.hs+1−1 src/Text/Pandoc/Writers/LaTeX.hs+7−2
src/Text/Pandoc/Readers/EPUB.hs+1−1
@@ -95,7 +95,7 @@ fetchImages mimes root arc (query iq -> links) =
9595 (mapMaybe getEntry links)
9696 where
9797 getEntry link =
98− let abslink = root </> link in
98+ let abslink = normalise (root </> link) in
9999 (link , lookup link mimes, ) . fromEntry
100100 <$> findEntryByPath abslink arc
101101
src/Text/Pandoc/Writers/LaTeX.hs+7−2
@@ -303,12 +303,17 @@ isLineBreakOrSpace _ = False
303303blockToLaTeX :: Block -- ^ Block to convert
304304 -> State WriterState Doc
305305blockToLaTeX Null = return empty
306−blockToLaTeX (Div (_,classes,_) bs) = do
306+blockToLaTeX (Div (identifier,classes,_) bs) = do
307307 beamer <- writerBeamer `fmap` gets stOptions
308+ ref <- toLabel identifier
309+ let linkAnchor = if null identifier
310+ then empty
311+ else "\\hyperdef{}" <> braces (text ref) <>
312+ braces ("\\label" <> braces (text ref))
308313 contents <- blockListToLaTeX bs
309314 if beamer && "notes" `elem` classes -- speaker notes
310315 then return $ "\\note" <> braces contents
311− else return contents
316+ else return (linkAnchor <> contents)
312317blockToLaTeX (Plain lst) =
313318 inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
314319-- title beginning with fig: indicates that the image is a figure