Skip to content

Commit

Permalink
RST reader: handle explicit reference links
Browse files Browse the repository at this point in the history
This case was missed when changing the reference link strategy for RST
to allow a single pass.
  • Loading branch information
silby committed Dec 21, 2024
1 parent 7f791f6 commit 2245358
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/Text/Pandoc/Readers/RST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <google_>` 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
Expand Down
22 changes: 22 additions & 0 deletions test/command/10484.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```
% pandoc -frst -tmarkdown_strict
- One issue fixed: `issue 123`_.
- One change merged: `Big change <pull 234_>`_.
- Improved the `home page <https://example.com/homepage>`_.
- 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).
```

0 comments on commit 2245358

Please sign in to comment.