From 7fbfcb03d87feb369dcfabc1066e8f570ed471c8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 7 Dec 2016 12:54:25 +0100 Subject: RST reader: fix hyperlink aliases. `link `_ .. _google: https://google.com is really a reference link. Closes #3283. --- src/Text/Pandoc/Readers/RST.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Text') 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 ` 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 -- cgit v1.2.3