diff options
Diffstat (limited to 'src/Text')
-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) |