aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-03-17 22:31:20 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-03-17 22:31:20 -0700
commitc3f9e8c12256d19ed6c89d15470945855ee16a94 (patch)
treec9fb8fb7b9bc6598770a4db6952f1afb381dc50b /src/Text
parent613c070cbd10b791bd097acd1b6b693a1e46eba1 (diff)
downloadpandoc-c3f9e8c12256d19ed6c89d15470945855ee16a94.tar.gz
Docx writer: make nsid in abstractNum deterministic.
Previously we assigned a random number (though in a deterministic way). But changes in the random package mean we get different results now on different architectures, even with the same random seed. We don't need random values; so now we just assign a value based on the list number id, which is guaranteed to be unique to the list marker.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index c47bfb2ea..20bcd0324 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -36,7 +36,6 @@ import qualified Data.Text.Lazy as TL
import Data.Time.Clock.POSIX
import Data.Digest.Pure.SHA (sha1, showDigest)
import Skylighting
-import System.Random (randomRs, mkStdGen)
import Text.Pandoc.BCP47 (getLang, renderLang)
import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang)
import qualified Text.Pandoc.Class.PandocMonad as P
@@ -695,8 +694,7 @@ baseListId = 1000
mkNumbering :: [ListMarker] -> [Element]
mkNumbering lists =
elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)]
- where elts = zipWith mkAbstractNum (ordNub lists) $
- randomRs (0x10000000, 0xFFFFFFFF) $ mkStdGen 1848
+ where elts = map mkAbstractNum (ordNub lists)
maxListLevel :: Int
maxListLevel = 8
@@ -713,10 +711,10 @@ mkNum marker numid =
$ mknode "w:startOverride" [("w:val",tshow start)] ())
[0..maxListLevel]
-mkAbstractNum :: ListMarker -> Integer -> Element
-mkAbstractNum marker nsid =
+mkAbstractNum :: ListMarker -> Element
+mkAbstractNum marker =
mknode "w:abstractNum" [("w:abstractNumId",listMarkerToId marker)]
- $ mknode "w:nsid" [("w:val", T.pack $ printf "%8x" nsid)] ()
+ $ mknode "w:nsid" [("w:val", "A" <> listMarkerToId marker)] ()
: mknode "w:multiLevelType" [("w:val","multilevel")] ()
: map (mkLvl marker)
[0..maxListLevel]