aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-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