Skip to content

Commit a67e5dc

Browse files
committed
WIP
1 parent bdac9e1 commit a67e5dc

File tree

1 file changed

+9
-41
lines changed

1 file changed

+9
-41
lines changed

docs/soar_manual/index_filter.lua

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,19 @@
1-
-- Comprehensive filter to catch HTML comments with index commands
1+
-- Simple test filter to add index entries
22

3-
function processAny(elem)
4-
-- Handle any element that might contain our HTML comments
5-
local text = ""
3+
function processDoc(doc)
4+
-- Insert multiple test index entries at the beginning
5+
table.insert(doc.blocks, 1, pandoc.RawBlock("latex", "\\index{chunking}"))
6+
table.insert(doc.blocks, 2, pandoc.RawBlock("latex", "\\index{test-entry}"))
7+
table.insert(doc.blocks, 3, pandoc.RawBlock("latex", "\\index{Soar}"))
68

7-
if elem.tag == "RawBlock" or elem.tag == "RawInline" then
8-
text = elem.text or ""
9-
elseif elem.tag == "Str" then
10-
text = elem.text or ""
11-
elseif elem.tag == "Para" then
12-
text = pandoc.utils.stringify(elem)
13-
end
9+
-- Also add some debug output
10+
io.stderr:write("Index filter: Added test index entries\n")
1411

15-
-- Look for HTML comments with index commands anywhere in the text
16-
if text and text:match("<!%-%-%s*\\index{.-}%s*-->") then
17-
-- Found an index comment - extract all index commands
18-
local index_commands = {}
19-
for index_cmd in text:gmatch("<!%-%-%s*(\\index{.-})%s*-->") do
20-
table.insert(index_commands, pandoc.RawInline("latex", index_cmd))
21-
end
22-
23-
-- If we found any, return them
24-
if #index_commands > 0 then
25-
if #index_commands == 1 then
26-
return index_commands[1]
27-
else
28-
return index_commands
29-
end
30-
end
31-
end
32-
33-
return elem
34-
end
35-
36-
-- Also try a document-level approach to insert some test index entries
37-
function processDocument(doc)
38-
-- Add a test index entry at the very beginning
39-
table.insert(doc.blocks, 1, pandoc.RawBlock("latex", "\\index{test-entry}"))
4012
return doc
4113
end
4214

4315
return {
4416
{
45-
RawBlock = processAny,
46-
RawInline = processAny,
47-
Str = processAny,
48-
Para = processAny,
49-
Pandoc = processDocument
17+
Pandoc = processDoc
5018
}
5119
}

0 commit comments

Comments
 (0)