aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-12-07 12:54:25 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-12-07 12:54:25 +0100
commit7fbfcb03d87feb369dcfabc1066e8f570ed471c8 (patch)
tree6e2697313deae47e9a4b5e13394cc506888b4d60 /src
parent97274c99910aab5daafecc4ebc0d04ff0c117b51 (diff)
downloadpandoc-7fbfcb03d87feb369dcfabc1066e8f570ed471c8.tar.gz
RST reader: fix hyperlink aliases.
`link <google_>`_ .. _google: https://google.com is really a reference link. Closes #3283.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 1b06c6f23..e3d94d7b4 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1120,14 +1120,22 @@ explicitLink = try $ do
notFollowedBy (char '`') -- `` marks start of inline code
label' <- trimInlines . mconcat <$>
manyTill (notFollowedBy (char '`') >> inline) (char '<')
- src <- manyTill (noneOf ">\n") (char '>')
+ src <- trim <$> manyTill (noneOf ">\n") (char '>')
skipSpaces
string "`_"
optional $ char '_' -- anonymous form
let label'' = if label' == mempty
then B.str src
else label'
- return $ B.link (escapeURI $ trim src) "" label''
+ -- `link <google_>` is a reference link to _google!
+ (src',tit,attr) <- case reverse src of
+ '_':xs -> do
+ keyTable <- stateKeys <$> getState
+ case M.lookup (toKey (reverse xs)) keyTable of
+ Nothing -> fail "no corresponding key"
+ Just ((s,t),a) -> return (s,t,a)
+ _ -> return (src, "", nullAttr)
+ return $ B.linkWith attr (escapeURI src') tit label''
referenceLink :: RSTParser Inlines
referenceLink = try $ do