aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-07-21 22:51:53 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-07-21 22:53:04 -0700
commit6419819b46c0d69c7024ba8aa4a6381cb311341c (patch)
tree8b3214ce8d2bc69184605d135d04cd71519f37ae /src/Text/Pandoc
parent748aa920f6cdbe5c7f828a706a048eda8340abc7 (diff)
downloadpandoc-6419819b46c0d69c7024ba8aa4a6381cb311341c.tar.gz
RST reader: fix double-link bug.
Link labels containing raw URLs were parsed as autolinks, but links within links are not allowed. Closes #4581.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 71a38cf82..2a36ca1f1 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -45,6 +45,7 @@ import Data.Maybe (fromMaybe, isJust)
import Data.Sequence (ViewR (..), viewr)
import Data.Text (Text)
import qualified Data.Text as T
+import Text.Pandoc.Walk (walk)
import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class (PandocMonad, fetchItem, readFileFromDirs)
@@ -1479,7 +1480,7 @@ explicitLink :: PandocMonad m => RSTParser m Inlines
explicitLink = try $ do
char '`'
notFollowedBy (char '`') -- `` marks start of inline code
- label' <- trimInlines . mconcat <$>
+ label' <- removeLinks . trimInlines . mconcat <$>
manyTill (notFollowedBy (char '`') >> inline) (char '<')
src <- trim <$> manyTill (noneOf ">\n") (char '>')
skipSpaces
@@ -1494,6 +1495,12 @@ explicitLink = try $ do
_ -> return ((src, ""), nullAttr)
return $ B.linkWith attr (escapeURI src') tit label''
+removeLinks :: B.Inlines -> B.Inlines
+removeLinks = B.fromList . walk (concatMap go) . B.toList
+ where go :: Inline -> [Inline]
+ go (Link _ lab _) = lab
+ go x = [x]
+
citationName :: PandocMonad m => RSTParser m String
citationName = do
raw <- citationMarker