diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-04-20 14:59:39 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-04-20 14:59:39 -0700 |
commit | a405b814596f5435d37388cacca4d81429f7104b (patch) | |
tree | c4fbab64f3eef4841271ab38fc151606a16767ba /src/Text/Pandoc/Writers | |
parent | 89d525e41775086146234cb35669626ab222eccc (diff) | |
download | pandoc-a405b814596f5435d37388cacca4d81429f7104b.tar.gz |
Add slash in internal links in reveal.js.
Closes #835.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index 0e1d35887..de48ef996 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -269,10 +269,13 @@ elementToListItem opts (Sec lev num (id',classes,_) headerText subsecs) let subList = if null subHeads then mempty else unordList opts subHeads + -- in reveal.js, we need #/apples, not #apples: + let revealSlash = ['/' | writerSlideVariant opts == RevealJsSlides] return $ Just $ if null id' then (H.a $ toHtml txt) >> subList - else (H.a ! A.href (toValue $ "#" ++ writerIdentifierPrefix opts ++ id') + else (H.a ! A.href (toValue $ "#" ++ revealSlash ++ + writerIdentifierPrefix opts ++ id') $ toHtml txt) >> subList elementToListItem _ _ = return Nothing @@ -477,9 +480,12 @@ blockToHtml opts (Header level (ident,_,_) lst) = do then (H.span ! A.class_ "header-section-number" $ toHtml $ showSecNum secnum) >> strToHtml " " >> contents else contents + let revealSlash = ['/' | writerSlideVariant opts == RevealJsSlides] let contents'' = if writerTableOfContents opts && not (null ident) then H.a ! A.href (toValue $ - '#' : writerIdentifierPrefix opts ++ ident) $ contents' + '#' : revealSlash ++ + writerIdentifierPrefix opts ++ + ident) $ contents' else contents' return $ case level of 1 -> H.h1 contents'' @@ -701,7 +707,11 @@ inlineToHtml opts inline = return $ obfuscateLink opts (renderHtml linkText) s (Link txt (s,tit)) -> do linkText <- inlineListToHtml opts txt - let link = H.a ! A.href (toValue s) $ linkText + let s' = case s of + '#':xs | writerSlideVariant opts == + RevealJsSlides -> '#':'/':xs + _ -> s + let link = H.a ! A.href (toValue s') $ linkText return $ if null tit then link else link ! A.title (toValue tit) @@ -732,7 +742,10 @@ inlineToHtml opts inline = htmlContents <- blockListToNote opts ref contents -- push contents onto front of notes put $ st {stNotes = (htmlContents:notes)} + let revealSlash = ['/' | writerSlideVariant opts + == RevealJsSlides] let link = H.a ! A.href (toValue $ "#" ++ + revealSlash ++ writerIdentifierPrefix opts ++ "fn" ++ ref) ! A.class_ "footnoteRef" ! prefixedId opts ("fnref" ++ ref) |