diff options
author | Joseph C. Sible <josephcsible@users.noreply.github.com> | 2020-03-30 15:03:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 12:03:29 -0700 |
commit | 4f41ac3269994c90173e07a6bedfbaeaec9e7be8 (patch) | |
tree | b88ea2164cda5c24ea782615decf5df279bfa343 /src | |
parent | a465e2c059ceb7f58279e25b11159c8fd391bde7 (diff) | |
download | pandoc-4f41ac3269994c90173e07a6bedfbaeaec9e7be8.tar.gz |
Fix #6228 (#6230)
UUID: Remove `getUUID`, fix `getRandomUUID` and make it polymorphic in PandocMonad.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/UUID.hs | 9 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs index 145bb80e2..ca0df2d0b 100644 --- a/src/Text/Pandoc/UUID.hs +++ b/src/Text/Pandoc/UUID.hs @@ -11,12 +11,13 @@ UUID generation using Version 4 (random method) described in RFC4122. See http://tools.ietf.org/html/rfc4122 -} -module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where +module Text.Pandoc.UUID ( UUID(..), getRandomUUID ) where import Data.Bits (clearBit, setBit) import Data.Word -import System.Random (RandomGen, getStdGen, randoms) +import System.Random (RandomGen, randoms) import Text.Printf (printf) +import Text.Pandoc.Class.PandocMonad data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8 @@ -56,5 +57,5 @@ getUUID gen = in UUID a b c d e f g' h i' j k l m n o p _ -> error "not enough random numbers for UUID" -- should not happen -getRandomUUID :: IO UUID -getRandomUUID = getUUID <$> getStdGen +getRandomUUID :: PandocMonad m => m UUID +getRandomUUID = getUUID <$> newStdGen diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index 49f6cc41c..63034a577 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -50,7 +50,7 @@ import Text.Pandoc.Options (EPUBVersion (..), HTMLMathMethod (..), import Text.Pandoc.Shared (makeSections, normalizeDate, renderTags', safeRead, stringify, trim, uniqueIdent, tshow) import qualified Text.Pandoc.UTF8 as UTF8 -import Text.Pandoc.UUID (getUUID) +import Text.Pandoc.UUID (getRandomUUID) import Text.Pandoc.Walk (query, walk, walkM) import Text.Pandoc.Writers.HTML (writeHtmlStringForEPUB) import Text.Printf (printf) @@ -163,8 +163,8 @@ getEPUBMetadata opts meta = do let addIdentifier m = if null (epubIdentifier m) then do - randomId <- (show . getUUID) <$> lift P.newStdGen - return $ m{ epubIdentifier = [Identifier randomId Nothing] } + randomId <- getRandomUUID + return $ m{ epubIdentifier = [Identifier (show randomId) Nothing] } else return m let addLanguage m = if null (epubLanguage m) |