Skip to content

Commit 364bb7c

Browse files
committed
WIP fix build
1 parent ec423b8 commit 364bb7c

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

docs/soar_manual/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pandoc \
2424
--listings \
2525
--number-sections \
2626
--lua-filter=docs/soar_manual/path_filter.lua \
27-
--lua-filter=docs/soar_manual/debug_filter.lua \
27+
--lua-filter=docs/soar_manual/index_filter.lua \
2828
-V geometry:"left=3cm, top=2.5cm, right=3cm, bottom=3cm" \
2929
-V has-index \
3030
docs/soar_manual/04_ProceduralKnowledgeLearning.md \

docs/soar_manual/index_filter.lua

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
-- This allows index entries to be hidden from MkDocs while being processed for PDF output
33

44
function extractIndexFromComments(elem)
5-
-- Handle RawInline and RawBlock elements with HTML format
6-
if (elem.tag == "RawInline" or elem.tag == "RawBlock") and elem.format == "html" then
7-
local comment = elem.text
5+
-- Handle RawInline and RawBlock elements with any format
6+
if elem.tag == "RawInline" or elem.tag == "RawBlock" then
7+
local text = elem.text or ""
88
-- Match HTML comments containing \index commands
9-
local index_cmd = comment:match("<!%-%-%s*\\index{(.-)}.-->")
9+
local index_cmd = text:match("<!%-%-%s*\\index{(.-)}.-->")
1010
if index_cmd then
1111
return pandoc.RawInline("latex", "\\index{" .. index_cmd .. "}")
1212
end
1313
-- Match full \index{...} commands in comments (allowing spaces)
14-
local full_index = comment:match("<!%-%-%s*(%\\index{.-})%s*-->")
14+
local full_index = text:match("<!%-%-%s*(%\\index{.-})%s*-->")
1515
if full_index then
1616
return pandoc.RawInline("latex", full_index)
1717
end
@@ -21,14 +21,18 @@ end
2121

2222
-- Also try to catch HTML comments that might be processed as plain text
2323
function extractFromPlainText(elem)
24-
if elem.tag == "Str" or elem.tag == "Para" then
25-
local text = elem.text or pandoc.utils.stringify(elem)
26-
if text and text:match("<!%-%-%s*\\index{.-}%s*-->") then
27-
-- Replace HTML comments with LaTeX index commands
28-
local new_text = text:gsub("<!%-%-%s*(\\index{.-})%s*-->", "%1")
29-
if new_text ~= text then
30-
return pandoc.RawInline("latex", new_text)
31-
end
24+
local text = ""
25+
if elem.tag == "Str" then
26+
text = elem.text or ""
27+
elseif elem.tag == "Para" then
28+
text = pandoc.utils.stringify(elem)
29+
end
30+
31+
if text and text:match("<!%-%-%s*\\index{.-}%s*-->") then
32+
-- Replace HTML comments with LaTeX index commands
33+
local new_text = text:gsub("<!%-%-%s*(\\index{.-})%s*-->", "%1")
34+
if new_text ~= text then
35+
return pandoc.RawInline("latex", new_text)
3236
end
3337
end
3438
return elem

0 commit comments

Comments
 (0)