LaTeX reader: support hyperref command.

Closes #7127.
This commit is contained in:
John MacFarlane 2021-03-07 13:21:45 -08:00
parent d560038342
commit c652dcc16b

View file

@ -398,17 +398,20 @@ inlineCommands = M.unions
, ("footnote", skipopts >> note <$> grouped block) , ("footnote", skipopts >> note <$> grouped block)
, ("passthrough", tok) -- \passthrough macro used by latex writer , ("passthrough", tok) -- \passthrough macro used by latex writer
-- for listings -- for listings
, ("includegraphics", do options <- option [] keyvals
src <- braced
mkImage options .
unescapeURL .
removeDoubleQuotes $ untokenize src)
-- hyperref
, ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$> , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
bracedUrl) bracedUrl)
, ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl) , ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
, ("href", do url <- bracedUrl , ("href", do url <- bracedUrl
sp sp
link (unescapeURL $ untokenize url) "" <$> tok) link (unescapeURL $ untokenize url) "" <$> tok)
, ("includegraphics", do options <- option [] keyvals
src <- braced
mkImage options . unescapeURL . removeDoubleQuotes $
untokenize src)
, ("hyperlink", hyperlink) , ("hyperlink", hyperlink)
, ("hyperref", hyperref)
, ("hypertarget", hypertargetInline) , ("hypertarget", hypertargetInline)
-- hyphenat -- hyphenat
, ("nohyphens", tok) , ("nohyphens", tok)
@ -463,6 +466,12 @@ hyperlink = try $ do
lab <- tok lab <- tok
return $ link ("#" <> src) "" lab return $ link ("#" <> src) "" lab
hyperref :: PandocMonad m => LP m Inlines
hyperref = try $ do
url <- (("#" <>) . untokenize <$> try (sp *> bracketedToks <* sp))
<|> untokenize <$> (bracedUrl <* bracedUrl <* bracedUrl)
link url "" <$> tok
hypertargetBlock :: PandocMonad m => LP m Blocks hypertargetBlock :: PandocMonad m => LP m Blocks
hypertargetBlock = try $ do hypertargetBlock = try $ do
ref <- untokenize <$> braced ref <- untokenize <$> braced