RST reader: treat undefined substitution references as plain text.

This mirrors rst2html behavior. Closes #11727.
This commit is contained in:
John MacFarlane
2026-06-23 12:05:52 +02:00
parent 090cb52f0a
commit 197ea8e8bd
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -170,7 +170,7 @@ parseRST = do
return doc
resolveBlockSubstitutions :: PandocMonad m => Block -> RSTParser m Block
resolveBlockSubstitutions x@(Para [Link _attr _ (s,_)])
resolveBlockSubstitutions (Para [Link _attr ils (s,_)])
| Just ref <- T.stripPrefix "##SUBST##" s = do
substTable <- stateSubstitutions <$> getState
let key@(Key key') = toKey $ stripFirstAndLast ref
@@ -178,7 +178,7 @@ resolveBlockSubstitutions x@(Para [Link _attr _ (s,_)])
Nothing -> do
pos <- getPosition
logMessage $ ReferenceNotFound (tshow key') pos
return x
return $ Para ils
Just target -> case
B.toList target of
[bl] -> return bl
@@ -233,7 +233,7 @@ resolveReferences x@(Link _ ils (s,_))
Nothing -> do
pos <- getPosition
logMessage $ ReferenceNotFound (tshow key') pos
return x
return $ Span ("",[],[]) ils
Just target -> case
B.toList target of
[Para [t]] -> return t
+8
View File
@@ -0,0 +1,8 @@
```
% pandoc -f rst -t markdown
[file|URL|PLAYLIST]
^D
2> [WARNING] Reference not found for '"url"' at line 4 column 1
\[file\|URL\|PLAYLIST\]
```