From 224535814fd1551cd1e6062127c810ac8e3a7dec Mon Sep 17 00:00:00 2001 From: Evan Silberman Date: Thu, 19 Dec 2024 18:43:24 -0800 Subject: [PATCH] RST reader: handle explicit reference links This case was missed when changing the reference link strategy for RST to allow a single pass. --- src/Text/Pandoc/Readers/RST.hs | 17 +++++++---------- test/command/10484.md | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 test/command/10484.md diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 7ccad218bea0..d8c886903727 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1704,22 +1704,19 @@ explicitLink = try $ do skipSpaces string "`_" optional $ char '_' -- anonymous form - ((src',tit),attr) <- - if isURI src - then return ((src, ""), nullAttr) - else - case T.unsnoc src of - -- `link ` is a reference link to _google! - Just (xs, '_') -> lookupKey [] (toKey xs) - _ -> return ((src, ""), nullAttr) + let src' | isURI src = escapeURI src + | otherwise = + case T.unsnoc src of + Just (xs, '_') -> "##REF##" <> xs + _ -> src let label'' = if label' == mempty then B.str src else label' let key = toKey $ stringify label' unless (key == Key mempty) $ do updateState $ \s -> s{ - stateKeys = M.insert key ((src',tit), attr) $ stateKeys s } - return $ B.linkWith attr (escapeURI src') tit label'' + stateKeys = M.insert key ((src',""), nullAttr) $ stateKeys s } + return $ B.linkWith nullAttr src' "" label'' citationName :: PandocMonad m => RSTParser m Text citationName = do diff --git a/test/command/10484.md b/test/command/10484.md new file mode 100644 index 000000000000..510446aa44ac --- /dev/null +++ b/test/command/10484.md @@ -0,0 +1,22 @@ +``` +% pandoc -frst -tmarkdown_strict +- One issue fixed: `issue 123`_. + +- One change merged: `Big change `_. + +- Improved the `home page `_. + +- One more `small change`__. + +.. _issue 123: https://github.com/joe/project/issues/123 +.. _pull 234: https://github.com/joe/project/pull/234 +__ https://github.com/joe/project/issues/999 + +^D +- One issue fixed: [issue + 123](https://github.com/joe/project/issues/123). +- One change merged: [Big + change](https://github.com/joe/project/pull/234). +- Improved the [home page](https://example.com/homepage). +- One more [small change](https://github.com/joe/project/issues/999). +```