diff options
| author | John MacFarlane <[email protected]> | 2023-11-22 23:24:55 -0500 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-11-22 23:24:55 -0500 |
| commit | a2a0f73eb816917839eeffad9e487394ebd88443 (patch) | |
| tree | 33814c81d4596645ecd18fa254b5a31aabd059c6 /src | |
| parent | 49e64c1451b9933a025d059f7dae287788c7d1cc (diff) | |
LaTeX writer: handle identifiers inside heading contents.
`\phantomsection` can't be used in this case, so we need `\hypertarget`.
Closes #9209.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX/Util.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs index 8dcec54dd..86b95795c 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Util.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs @@ -260,8 +260,14 @@ wrapDiv (_,classes,kvs) t = do hypertarget :: PandocMonad m => Text -> LW m (Doc Text) hypertarget "" = return mempty hypertarget ident = do - label <- labelFor ident - return $ text "\\phantomsection" <> label + inHeading <- gets stInHeading + if inHeading + then do -- see #9209 (these cases should be rare) + ref <- literal <$> toLabel ident + return $ text "\\protect\\hypertarget" <> braces ref <> "{}" + else do + label <- labelFor ident + return $ text "\\phantomsection" <> label labelFor :: PandocMonad m => Text -> LW m (Doc Text) labelFor "" = return empty |
