Skip to content

Commit 5b43b3b

Browse files
committed
WIP fix build
1 parent 364bb7c commit 5b43b3b

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

docs/soar_manual/04_ProceduralKnowledgeLearning.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
<!-- markdownlint-disable-next-line -->
22
# Procedural Knowledge Learning
33

4-
<!-- \index{chunking} -->
5-
<!-- \index{chunk} -->
6-
<!-- \index{result} -->
7-
<!-- \index{subgoal} -->
4+
\index{chunking}\index{chunk}\index{result}\index{subgoal}
85

96
## Chunking
107

docs/soar_manual/index_filter.lua

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
1-
-- Pandoc Lua filter to extract LaTeX index commands from HTML comments
2-
-- This allows index entries to be hidden from MkDocs while being processed for PDF output
1+
-- Pandoc Lua filter to extract LaTeX index commands
2+
-- This allows index entries to be included in PDF output while being invisible in MkDocs
33

4-
function extractIndexFromComments(elem)
5-
-- Handle RawInline and RawBlock elements with any format
6-
if elem.tag == "RawInline" or elem.tag == "RawBlock" then
4+
function processIndexCommands(elem)
5+
-- Handle RawInline and RawBlock elements with LaTeX format
6+
if elem.tag == "RawInline" and elem.format == "latex" then
77
local text = elem.text or ""
8-
-- Match HTML comments containing \index commands
9-
local index_cmd = text:match("<!%-%-%s*\\index{(.-)}.-->")
10-
if index_cmd then
11-
return pandoc.RawInline("latex", "\\index{" .. index_cmd .. "}")
12-
end
13-
-- Match full \index{...} commands in comments (allowing spaces)
14-
local full_index = text:match("<!%-%-%s*(%\\index{.-})%s*-->")
15-
if full_index then
16-
return pandoc.RawInline("latex", full_index)
8+
-- If it contains \index commands, pass them through
9+
if text:match("\\index{.-}") then
10+
return elem -- Pass through as-is
1711
end
1812
end
1913
return elem
2014
end
2115

22-
-- Also try to catch HTML comments that might be processed as plain text
23-
function extractFromPlainText(elem)
24-
local text = ""
16+
-- Convert standalone \index{} commands in text to raw LaTeX
17+
function convertIndexToRaw(elem)
2518
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)
19+
local text = elem.text or ""
20+
-- If the entire string is just \index commands, convert to raw LaTeX
21+
if text:match("^\\index{.-}+$") then
22+
return pandoc.RawInline("latex", text)
23+
end
24+
-- If it contains \index commands mixed with other text, extract them
25+
if text:match("\\index{.-}") then
26+
local parts = {}
27+
local last_end = 1
28+
for index_cmd in text:gmatch("(\\index{.-})") do
29+
local start_pos, end_pos = text:find(index_cmd, last_end, true)
30+
if start_pos > last_end then
31+
table.insert(parts, pandoc.Str(text:sub(last_end, start_pos - 1)))
32+
end
33+
table.insert(parts, pandoc.RawInline("latex", index_cmd))
34+
last_end = end_pos + 1
35+
end
36+
if last_end <= #text then
37+
table.insert(parts, pandoc.Str(text:sub(last_end)))
38+
end
39+
return parts
3640
end
3741
end
3842
return elem
3943
end
4044

4145
return {
4246
{
43-
RawInline = extractIndexFromComments,
44-
RawBlock = extractIndexFromComments,
45-
Str = extractFromPlainText,
46-
Para = extractFromPlainText
47+
RawInline = processIndexCommands,
48+
Str = convertIndexToRaw
4749
}
4850
}

0 commit comments

Comments
 (0)