@@ -1391,11 +1391,8 @@ inlineCommands = M.fromList $
13911391 <|> citation "citeauthor" AuthorInText False)
13921392 , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
13931393 addMeta "nocite"))
1394− -- hyperlink: for now, we just preserve contents.
1395− -- we might add the actual links, but we need to avoid clashes
1396− -- with ids produced by label.
1397− , ("hypertarget", braced >> tok)
1398− , ("hyperlink", braced >> tok)
1394+ , ("hyperlink", hyperlink)
1395+ , ("hypertarget", hypertargetInline)
13991396 -- glossaries package
14001397 , ("gls", doAcronym "short")
14011398 , ("Gls", doAcronym "short")
@@ -1450,6 +1447,26 @@ inlineCommands = M.fromList $
14501447 , ("Rn", romanNumeralLower)
14511448 ]
14521449
1450+hyperlink :: PandocMonad m => LP m Inlines
1451+hyperlink = try $ do
1452+ src <- toksToString <$> braced
1453+ lab <- tok
1454+ return $ link ('#':src) "" lab
1455+
1456+hypertargetBlock :: PandocMonad m => LP m Blocks
1457+hypertargetBlock = try $ do
1458+ ref <- toksToString <$> braced
1459+ bs <- grouped block
1460+ case toList bs of
1461+ [Header 1 (ident,_,_) _] | ident == ref -> return bs
1462+ _ -> return $ divWith (ref, [], []) bs
1463+
1464+hypertargetInline :: PandocMonad m => LP m Inlines
1465+hypertargetInline = try $ do
1466+ ref <- toksToString <$> braced
1467+ ils <- grouped inline
1468+ return $ spanWith (ref, [], []) ils
1469+
14531470romanNumeralUpper :: (PandocMonad m) => LP m Inlines
14541471romanNumeralUpper =
14551472 str . toRomanNumeral <$> romanNumeralArg
@@ -1972,7 +1989,7 @@ blockCommands = M.fromList $
19721989 , ("setdefaultlanguage", setDefaultLanguage)
19731990 , ("setmainlanguage", setDefaultLanguage)
19741991 -- hyperlink
1975− , ("hypertarget", try $ braced >> grouped block)
1992+ , ("hypertarget", hypertargetBlock)
19761993 -- LaTeX colors
19771994 , ("textcolor", coloredBlock "color")
19781995 , ("colorbox", coloredBlock "background-color")