diff options
| author | John MacFarlane <[email protected]> | 2023-05-29 13:05:34 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-05-29 13:05:34 -0700 |
| commit | 0e0c00db5159c6edad01b95a5b3047315fb40780 (patch) | |
| tree | 4b1a1cdbd3b81c702785ebcdfd2e3f1081319194 | |
| parent | 4ea1980699e3e2819800084565910a5b0f7a2bb8 (diff) | |
RST redear: Fix sorting on anonymous keys.
This fixes a bug in RST documents that have anonymous links.
Closes #8877.
| -rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index dcaddaa60..08ea50155 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -25,6 +25,7 @@ import Data.Maybe (fromMaybe, maybeToList, isJust) import Data.Sequence (ViewR (..), viewr) import Data.Text (Text) import qualified Data.Text as T +import Text.Printf (printf) import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem, getTimestamp) @@ -1164,14 +1165,14 @@ substKey = try $ do updateState $ \s -> s{ stateSubstitutions = M.insert key il $ stateSubstitutions s } -anonymousKey :: Monad m => RSTParser m () +anonymousKey :: PandocMonad m => RSTParser m () anonymousKey = try $ do oneOfStrings [".. __:", "__"] src <- targetURI -- we need to ensure that the keys are ordered by occurrence in -- the document. numKeys <- M.size . stateKeys <$> getState - let key = toKey $ "_" <> T.pack (show numKeys) + let key = toKey $ "_" <> T.pack (printf "%04d" numKeys) updateState $ \s -> s { stateKeys = M.insert key ((src,""), nullAttr) $ stateKeys s } |
