aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-03-07 13:21:45 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-03-07 13:22:00 -0800
commitc652dcc16b208954ab30a27b1c72a889b20ef2e9 (patch)
tree12b2e4dac60a55d8bc8c9c6a96d9b85654174630 /src/Text/Pandoc
parentd560038342ad45fabd10be85d8343d05d7f20c92 (diff)
downloadpandoc-c652dcc16b208954ab30a27b1c72a889b20ef2e9.tar.gz
LaTeX reader: support hyperref command.
Closes #7127.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 552411db8..ceac261d2 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -398,17 +398,20 @@ inlineCommands = M.unions
, ("footnote", skipopts >> note <$> grouped block)
, ("passthrough", tok) -- \passthrough macro used by latex writer
-- for listings
+ , ("includegraphics", do options <- option [] keyvals
+ src <- braced
+ mkImage options .
+ unescapeURL .
+ removeDoubleQuotes $ untokenize src)
+ -- hyperref
, ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
bracedUrl)
, ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
, ("href", do url <- bracedUrl
sp
link (unescapeURL $ untokenize url) "" <$> tok)
- , ("includegraphics", do options <- option [] keyvals
- src <- braced
- mkImage options . unescapeURL . removeDoubleQuotes $
- untokenize src)
, ("hyperlink", hyperlink)
+ , ("hyperref", hyperref)
, ("hypertarget", hypertargetInline)
-- hyphenat
, ("nohyphens", tok)
@@ -463,6 +466,12 @@ hyperlink = try $ do
lab <- tok
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 = try $ do
ref <- untokenize <$> braced