git.iko.soy/typeable/pandoc
on master help sign in
Fix #6228 (#6230)
4f41ac3Joseph C. Sible
src/Text/Pandoc/UUID.hs+5−4
@@ -11,12 +11,13 @@ UUID generation using Version 4 (random method) described
11in RFC4122. See http://tools.ietf.org/html/rfc4122
11in RFC4122. See http://tools.ietf.org/html/rfc4122
12-}
12-}
13
13
14−module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where
14+module Text.Pandoc.UUID ( UUID(..), getRandomUUID ) where
15
15
16import Data.Bits (clearBit, setBit)
16import Data.Bits (clearBit, setBit)
17import Data.Word
17import Data.Word
18−import System.Random (RandomGen, getStdGen, randoms)
18+import System.Random (RandomGen, randoms)
19import Text.Printf (printf)
19import Text.Printf (printf)
20+import Text.Pandoc.Class.PandocMonad
20
21
21data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
22data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
22 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
23 Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
@@ -56,5 +57,5 @@ getUUID gen =
56 in UUID a b c d e f g' h i' j k l m n o p
57 in UUID a b c d e f g' h i' j k l m n o p
57 _ -> error "not enough random numbers for UUID" -- should not happen
58 _ -> error "not enough random numbers for UUID" -- should not happen
58
59
59−getRandomUUID :: IO UUID
60+getRandomUUID :: PandocMonad m => m UUID
60−getRandomUUID = getUUID <$> getStdGen
61+getRandomUUID = getUUID <$> newStdGen
src/Text/Pandoc/Writers/EPUB.hs+3−3
@@ -50,7 +50,7 @@ import Text.Pandoc.Options (EPUBVersion (..), HTMLMathMethod (..),
50import Text.Pandoc.Shared (makeSections, normalizeDate, renderTags',
50import Text.Pandoc.Shared (makeSections, normalizeDate, renderTags',
51 safeRead, stringify, trim, uniqueIdent, tshow)
51 safeRead, stringify, trim, uniqueIdent, tshow)
52import qualified Text.Pandoc.UTF8 as UTF8
52import qualified Text.Pandoc.UTF8 as UTF8
53−import Text.Pandoc.UUID (getUUID)
53+import Text.Pandoc.UUID (getRandomUUID)
54import Text.Pandoc.Walk (query, walk, walkM)
54import Text.Pandoc.Walk (query, walk, walkM)
55import Text.Pandoc.Writers.HTML (writeHtmlStringForEPUB)
55import Text.Pandoc.Writers.HTML (writeHtmlStringForEPUB)
56import Text.Printf (printf)
56import Text.Printf (printf)
@@ -163,8 +163,8 @@ getEPUBMetadata opts meta = do
163 let addIdentifier m =
163 let addIdentifier m =
164 if null (epubIdentifier m)
164 if null (epubIdentifier m)
165 then do
165 then do
166− randomId <- (show . getUUID) <$> lift P.newStdGen
166+ randomId <- getRandomUUID
167− return $ m{ epubIdentifier = [Identifier randomId Nothing] }
167+ return $ m{ epubIdentifier = [Identifier (show randomId) Nothing] }
168 else return m
168 else return m
169 let addLanguage m =
169 let addLanguage m =
170 if null (epubLanguage m)
170 if null (epubLanguage m)