Skip to content

Commit 312ac69

Browse files
committed
move local declarations into function to avoid hitting max # locals Lua limit
1 parent d121ca0 commit 312ac69

1 file changed

Lines changed: 25 additions & 26 deletions

File tree

src/resources/filters/quarto-pre/llms-conditional-content.lua

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,36 @@
66
-- from llms.md output independently of the HTML format.
77
-- Only runs when llms-txt is enabled (guarded by filterIf in main.lua).
88

9-
local constants = require("modules/constants")
10-
11-
local function list_contains(list, value)
12-
if not list then return false end
13-
for _, v in ipairs(list) do
14-
if v == value then return true end
15-
end
16-
return false
17-
end
9+
function llms_resolve_conditional_content()
10+
-- Determine if a ConditionalBlock should be visible for llms-txt output.
11+
-- Returns true (include), false (exclude), or nil (no llms-txt condition).
12+
local function is_llms_visible(tbl)
13+
local constants = require("modules/constants")
14+
local function list_contains(list, value)
15+
if not list then return false end
16+
for _, v in ipairs(list) do
17+
if v == value then return true end
18+
end
19+
return false
20+
end
1821

19-
-- Determine if a ConditionalBlock should be visible for llms-txt output.
20-
-- Returns true (include), false (exclude), or nil (no llms-txt condition).
21-
local function is_llms_visible(tbl)
22-
local cond = tbl.condition
23-
local has_when = list_contains(cond[constants.kWhenFormat], "llms-txt")
24-
local has_unless = list_contains(cond[constants.kUnlessFormat], "llms-txt")
22+
local cond = tbl.condition
23+
local has_when = list_contains(cond[constants.kWhenFormat], "llms-txt")
24+
local has_unless = list_contains(cond[constants.kUnlessFormat], "llms-txt")
2525

26-
if not has_when and not has_unless then return nil end
26+
if not has_when and not has_unless then return nil end
2727

28-
if tbl.behavior == constants.kContentVisible then
29-
-- content-visible when-format="llms-txt" -> include for llms
30-
-- content-visible unless-format="llms-txt" -> exclude for llms
31-
return has_when
32-
else -- content-hidden
33-
-- content-hidden when-format="llms-txt" -> exclude for llms
34-
-- content-hidden unless-format="llms-txt" -> include for llms
35-
return has_unless
28+
if tbl.behavior == constants.kContentVisible then
29+
-- content-visible when-format="llms-txt" -> include for llms
30+
-- content-visible unless-format="llms-txt" -> exclude for llms
31+
return has_when
32+
else -- content-hidden
33+
-- content-hidden when-format="llms-txt" -> exclude for llms
34+
-- content-hidden unless-format="llms-txt" -> include for llms
35+
return has_unless
36+
end
3637
end
37-
end
3838

39-
function llms_resolve_conditional_content()
4039
return {
4140
ConditionalBlock = function(tbl)
4241
local llms_visible = is_llms_visible(tbl)

0 commit comments

Comments
 (0)