git.iko.soy/typeable/pandoc
on master help sign in
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.

commitc3f9e8c12256d19ed6c89d15470945855ee16a94 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 17 Mar 2021, 22:31 (6 years ago) parent613c070
34 files changed+4−6
src/Text/Pandoc/Writers/Docx.hs+4−6 test/docx/golden/block_quotes.docx test/docx/golden/codeblock.docx test/docx/golden/comments.docx test/docx/golden/custom_style_no_reference.docx test/docx/golden/custom_style_preserve.docx test/docx/golden/custom_style_reference.docx test/docx/golden/definition_list.docx test/docx/golden/document-properties-short-desc.docx test/docx/golden/document-properties.docx test/docx/golden/headers.docx test/docx/golden/image.docx test/docx/golden/inline_code.docx test/docx/golden/inline_formatting.docx test/docx/golden/inline_images.docx test/docx/golden/link_in_notes.docx test/docx/golden/links.docx test/docx/golden/lists.docx test/docx/golden/lists_continuing.docx test/docx/golden/lists_multiple_initial.docx test/docx/golden/lists_restarting.docx test/docx/golden/nested_anchors_in_header.docx test/docx/golden/notes.docx test/docx/golden/raw-blocks.docx test/docx/golden/raw-bookmarks.docx test/docx/golden/table_one_row.docx test/docx/golden/table_with_list_cell.docx test/docx/golden/tables.docx test/docx/golden/track_changes_deletion.docx test/docx/golden/track_changes_insertion.docx test/docx/golden/track_changes_move.docx test/docx/golden/track_changes_scrubbed_metadata.docx test/docx/golden/unicode.docx test/docx/golden/verbatim_subsuper.docx
src/Text/Pandoc/Writers/Docx.hs+4−6
@@ -36,7 +36,6 @@ import qualified Data.Text.Lazy as TL
3636import Data.Time.Clock.POSIX
3737import Data.Digest.Pure.SHA (sha1, showDigest)
3838import Skylighting
39−import System.Random (randomRs, mkStdGen)
4039import Text.Pandoc.BCP47 (getLang, renderLang)
4140import Text.Pandoc.Class.PandocMonad (PandocMonad, report, toLang)
4241import qualified Text.Pandoc.Class.PandocMonad as P
@@ -695,8 +694,7 @@ baseListId = 1000
695694mkNumbering :: [ListMarker] -> [Element]
696695mkNumbering lists =
697696 elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)]
698− where elts = zipWith mkAbstractNum (ordNub lists) $
699− randomRs (0x10000000, 0xFFFFFFFF) $ mkStdGen 1848
697+ where elts = map mkAbstractNum (ordNub lists)
700698
701699maxListLevel :: Int
702700maxListLevel = 8
@@ -713,10 +711,10 @@ mkNum marker numid =
713711 $ mknode "w:startOverride" [("w:val",tshow start)] ())
714712 [0..maxListLevel]
715713
716−mkAbstractNum :: ListMarker -> Integer -> Element
717−mkAbstractNum marker nsid =
714+mkAbstractNum :: ListMarker -> Element
715+mkAbstractNum marker =
718716 mknode "w:abstractNum" [("w:abstractNumId",listMarkerToId marker)]
719− $ mknode "w:nsid" [("w:val", T.pack $ printf "%8x" nsid)] ()
717+ $ mknode "w:nsid" [("w:val", "A" <> listMarkerToId marker)] ()
720718 : mknode "w:multiLevelType" [("w:val","multilevel")] ()
721719 : map (mkLvl marker)
722720 [0..maxListLevel]
test/docx/golden/block_quotes.docx

Binary file not shown.

test/docx/golden/codeblock.docx

Binary file not shown.

test/docx/golden/comments.docx

Binary file not shown.

test/docx/golden/custom_style_no_reference.docx

Binary file not shown.

test/docx/golden/custom_style_preserve.docx

Binary file not shown.

test/docx/golden/custom_style_reference.docx

Binary file not shown.

test/docx/golden/definition_list.docx

Binary file not shown.

test/docx/golden/document-properties-short-desc.docx

Binary file not shown.

test/docx/golden/document-properties.docx

Binary file not shown.

test/docx/golden/headers.docx

Binary file not shown.

test/docx/golden/image.docx

Binary file not shown.

test/docx/golden/inline_code.docx

Binary file not shown.

test/docx/golden/inline_formatting.docx

Binary file not shown.

test/docx/golden/inline_images.docx

Binary file not shown.

test/docx/golden/link_in_notes.docx

Binary file not shown.

test/docx/golden/links.docx

Binary file not shown.

test/docx/golden/lists.docx

Binary file not shown.

test/docx/golden/lists_continuing.docx

Binary file not shown.

test/docx/golden/lists_multiple_initial.docx

Binary file not shown.

test/docx/golden/lists_restarting.docx

Binary file not shown.

test/docx/golden/nested_anchors_in_header.docx

Binary file not shown.

test/docx/golden/notes.docx

Binary file not shown.

test/docx/golden/raw-blocks.docx

Binary file not shown.

test/docx/golden/raw-bookmarks.docx

Binary file not shown.

test/docx/golden/table_one_row.docx

Binary file not shown.

test/docx/golden/table_with_list_cell.docx

Binary file not shown.

test/docx/golden/tables.docx

Binary file not shown.

test/docx/golden/track_changes_deletion.docx

Binary file not shown.

test/docx/golden/track_changes_insertion.docx

Binary file not shown.

test/docx/golden/track_changes_move.docx

Binary file not shown.

test/docx/golden/track_changes_scrubbed_metadata.docx

Binary file not shown.

test/docx/golden/unicode.docx

Binary file not shown.

test/docx/golden/verbatim_subsuper.docx

Binary file not shown.