uuid in code listings

5 views
Skip to first unread message

Matti Picus

unread,
Jan 12, 2021, 8:31:57 AM1/12/21
to nikola-...@googlegroups.com

Why do code blocks get their own unique "anchor_ref = 'rest_code_' + uuid.uuid4().hex" ref? I would like to have a reproducable build. Could we use a random.randint(0, 0xffff) instead and then random.seed(n) could be set at the beginning of the build.


Matti

Chris Warrick

unread,
Jan 12, 2021, 3:00:49 PM1/12/21
to Nikola—Discuss
On Tue, 12 Jan 2021 at 14:31, Matti Picus <matti...@gmail.com> wrote:
>
> Why do code blocks get their own unique "anchor_ref = 'rest_code_' + uuid.uuid4().hex" ref? I would like to have a reproducable build. Could we use a random.randint(0, 0xffff) instead and then random.seed(n) could be set at the beginning of the build.

Lines in a code block must have unique anchors on all pages they
appear on. A UUID guarantees no collisions and requires no special
state tracking. An alternate and more deterministic solution would
need to take the full input file name into account, and keep track of
the number of code blocks already rendered — perhaps doable, but
requires more work, and might be ugly/expose internal details.

Why do you want a reproducible build?

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16
Reply all
Reply to author
Forward
0 new messages