Initial commit
Build, test, deploy / site (push) Failing after 15m13s

This commit is contained in:
alexm committed 2026-11-12 22:24:02 -05:00
commit e092cb029c
252 files changed
+35037

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
-- Runs the extension's shortcodes outside Quarto, with the few `quarto` functions they use stubbed, and prints one
-- JSON line per call for tests/quarto.test.mjs. Usage: pandoc lua harness.lua <ext> <page dir> <calls.json>
--
-- A call is either the options of {{< pplus >}} ({ pseudo = "x.pseudo", ... }), or { sc = "pplus-run", kw = {...},
-- meta = {...} } for any shortcode. The line holds what the blocks came to: the iframe's src and height, the code
-- blocks (language and text), the links, the raw HTML, the classes of every Div, and the tab titles.
local ext, dir, calls_file = arg[1], arg[2], arg[3]
local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local function b64(data)
return ((data:gsub('.', function(x) local r, b = '', x:byte() for i = 8, 1, -1 do r = r .. (b % 2 ^ i - b % 2 ^ (i - 1) > 0 and '1' or '0') end return r end) .. '0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if #x < 6 then return '' end local c = 0 for i = 1, 6 do c = c + (x:sub(i, i) == '1' and 2 ^ (6 - i) or 0) end return b64chars:sub(c + 1, c + 1) end) .. ({ '', '==', '=' })[#data % 3 + 1])
end
local format = os.getenv('PPLUS_FORMAT') or 'html'
quarto = { doc = { input_file = dir .. '/index.qmd', is_format = function(f) return f == format end, add_html_dependency = function() end },
base64 = { encode = b64 }, json = { encode = pandoc.json.encode } }
local shortcodes = dofile(ext .. '/pplus.lua')
local f = io.open(calls_file); local calls = pandoc.json.decode(f:read('a'), false); f:close()
local function str_table(t) local out = {} for k, v in pairs(t or {}) do out[k] = pandoc.Str(tostring(v)) end return out end
for _, call in ipairs(calls) do
local name, kw, meta = 'pplus', call, {}
if call.sc then name, kw, meta = call.sc, call.kw or {}, call.meta or {} end
local out = { codes = {}, links = {}, raw = {}, divs = {}, maths = {} }
local blocks = shortcodes[name]({}, kw, str_table(meta))
pandoc.Div(blocks):walk({
RawBlock = function(blk)
out.raw[#out.raw + 1] = blk.text
local src = blk.text:match('<iframe[^>]-src="([^"]+)"')
if src then out.src = src:gsub('&amp;', '&'); out.height = blk.text:match('<iframe[^>]-height="(%d+)"') end
end,
CodeBlock = function(blk) out.codes[#out.codes + 1] = { lang = blk.classes[1], text = blk.text } end,
Link = function(l) out.links[#out.links + 1] = l.target end,
Div = function(d) if #d.classes > 0 then out.divs[#out.divs + 1] = table.concat(d.classes, ' ') end end,
Math = function(m) out.maths[#out.maths + 1] = m.text end,
})
print(pandoc.json.encode(out))
end