diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-03-16 10:15:14 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-03-16 10:15:14 +0100 |
commit | 38c3a683468428fc26485f3346bdbbb4eb7d6ef2 (patch) | |
tree | 51b8782fb07631d62fc508ac81ef2fba9791336f /src/Text | |
parent | 257d96f199c1521cde0ee7147996e8c6e78a306c (diff) | |
download | pandoc-38c3a683468428fc26485f3346bdbbb4eb7d6ef2.tar.gz |
LaTeX/Beamer writer: allow hyperlinks to frames.
Previously you could link to a header above or below slide
level but not TO slide level. This commit changes that.
Hypertargets are inserted inside frame titles; technically
the reference is to just after the title, but in normal
use (where slides are viewed full screen in a slide show),
this does not matter.
Closes #3220.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 7e1970d01..44c00df24 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -390,10 +390,19 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts) let options = if null optionslist then "" else "[" ++ intercalate "," optionslist ++ "]" - let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ options) : - if tit == [Str "\0"] -- marker for hrule - then [] - else (RawInline "latex" "{") : tit ++ [RawInline "latex" "}"] + let latex = RawInline (Format "latex") + slideTitle <- + if tit == [Str "\0"] -- marker for hrule + then return [] + else + if null ident + then return $ latex "{" : tit ++ [latex "}"] + else do + ref <- toLabel ident + return $ latex ("{%\n\\protect\\hypertarget{" ++ + ref ++ "}{%\n") : tit ++ [latex "}}"] + let slideStart = Para $ + RawInline "latex" ("\\begin{frame}" ++ options) : slideTitle let slideEnd = RawBlock "latex" "\\end{frame}" -- now carve up slide into blocks if there are sections inside bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts |