diff options
| author | John MacFarlane <[email protected]> | 2024-10-15 11:25:28 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-10-15 11:25:28 -0700 |
| commit | 300e18efba40b1735ddd024df5281c90889a0bdd (patch) | |
| tree | 6a00719135e2243fcd652f2f86f4e268adbde718 /src | |
| parent | e9e1684c9ede8aeef4f7b4be5403b5de4603781b (diff) | |
RST reader: support inline anchors.
Closes #9196.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index f6203476f..1860b14fe 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1394,6 +1394,7 @@ table = gridTable <|> simpleTable False <|> simpleTable True <?> "table" inline :: PandocMonad m => RSTParser m Inlines inline = choice [ note -- can start with whitespace, so try before ws , link + , inlineAnchor , strong , emph , code @@ -1721,3 +1722,13 @@ note = try $ do smart :: PandocMonad m => RSTParser m Inlines smart = smartPunctuation inline + +inlineAnchor :: PandocMonad m => RSTParser m Inlines +inlineAnchor = do + char '_' + name <- quotedReferenceName <|> simpleReferenceName + let ident = textToIdentifier mempty name + updateState $ \s -> + s{ stateKeys = M.insert (toKey name) (("#" <> ident, ""), nullAttr) + (stateKeys s) } + pure $ B.spanWith (ident,[],[]) (B.text name) |
