Repository navigation
GLightbox options cause HTML output to change #11122
Description
Activity
I don't know Lua but using
pairsByKeysforoptionsJsonmay solve the problem:quarto-cli/src/resources/pandoc/datadir/_utils.lua
Lines 24 to 25 in 7194553
-- https://www.lua.org/pil/19.3.html local pairsByKeys = function (t, f) quarto-cli/tests/docs/extensions/basic/_extensions/quarto-ext/lightbox/lightbox.lua
Lines 181 to 184 in 7194553
local optionsJson = quarto.json.encode(options) -- generate the initialization script with the correct options local scriptTag = "<script>var lightboxQuarto = GLightbox(" .. optionsJson .. ");</script>" - local optionsJson = quarto.json.encode(options) + local optionsJson = pairsByKeys(quarto.json.encode(options))
Thanks, I thought I add open an issue about this four months ago but apparently not since I can't find it ...
Here the relevant comments/codes from the previous discussion:
-
quarto-cli/src/resources/filters/layout/lightbox.lua
Lines 371 to 382 in 7194553
-- Generate the options to configure lightbox local options = { selector = selector, closeEffect = effect, openEffect = effect, descPosition = descPosition, loop = loop, } if skin ~= nil then options.skin = skin end local optionsJson = quarto.json.encode(options) -
we have implemented sortedPairs multiple times throughout the codebase... we should pull it into quarto.utils.table and then just use that
quarto-cli/src/resources/pandoc/datadir/_utils.lua
Lines 239 to 252 in 7194553
local function sortedPairs(t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function() -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end
Reacted by Winnie-
- addedenhancementNew feature or requestNew feature or requestand removedbugSomething isn't workingSomething isn't working
on Oct 20, 2024 I made an attempt to fix this in #11124
Bug description
Order of GLightbox options changes on (almost) every HTML rendering. This may sound like a minor cosmetic detail but it causes the checksum of the output file to change and therefore makes caching more difficult.
Steps to reproduce
Use any document containing an image, e.g.
run the following commands:
quarto render --to html --output-dir output1 quarto render --to html --output-dir output2 # you may need to run this step more than once diff output1/index.html output2/index.htmlExpected behavior
Output does not differ because input has not changed.
Actual behavior
Order of GLightbox options is changed, e.g.
Your environment
nixos-version: 24.05.20241012.a3f9ad6 (Uakari)
Quarto check output
quarto check