Skip to content

Commit 270cf1c

Browse files
committed
WIP
1 parent 75d187f commit 270cf1c

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

docs/soar_manual/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pandoc \
2424
--listings \
2525
--number-sections \
2626
--lua-filter=docs/soar_manual/path_filter.lua \
27+
--lua-filter=docs/soar_manual/index_filter.lua \
2728
-V geometry:"left=3cm, top=2.5cm, right=3cm, bottom=3cm" \
2829
-V has-index \
2930
docs/soar_manual/01_Introduction.md \

docs/soar_manual/index_filter.lua

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,29 @@
1-
-- Simple Pandoc Lua filter to add index entries
2-
-- For now, let's just add some basic index entries manually
1+
-- Simple filter to convert HTML comments with \index commands to LaTeX
32

4-
function addIndexEntries(meta)
5-
-- This function runs once per document
6-
return meta
3+
function processBlock(block)
4+
if block.tag == "RawBlock" and block.format == "html" then
5+
local text = block.text
6+
-- Check if this is an HTML comment with \index
7+
local index_match = text:match("^<!%-%-%s*\\index{(.-)}.-->$")
8+
if index_match then
9+
return pandoc.RawBlock("latex", "\\index{" .. index_match .. "}")
10+
end
11+
end
12+
return block
713
end
814

9-
function processDocument(doc)
10-
-- Add some basic index entries at the beginning of the document
11-
local index_entries = {
12-
pandoc.RawBlock("latex", "\\index{chunking}"),
13-
pandoc.RawBlock("latex", "\\index{chunk}"),
14-
pandoc.RawBlock("latex", "\\index{result}"),
15-
pandoc.RawBlock("latex", "\\index{subgoal}"),
16-
pandoc.RawBlock("latex", "\\index{instantiation}"),
17-
pandoc.RawBlock("latex", "\\index{chunking!backtracing}"),
18-
pandoc.RawBlock("latex", "\\index{singleton}"),
19-
pandoc.RawBlock("latex", "\\index{chunking!explanation-based behavior summarization}")
20-
}
21-
22-
-- Insert index entries at the beginning
23-
for i = #index_entries, 1, -1 do
24-
table.insert(doc.blocks, 1, index_entries[i])
15+
function processInline(inline)
16+
if inline.tag == "RawInline" and inline.format == "html" then
17+
local text = inline.text
18+
-- Check if this is an HTML comment with \index
19+
local index_match = text:match("^<!%-%-%s*\\index{(.-)}.-->$")
20+
if index_match then
21+
return pandoc.RawInline("latex", "\\index{" .. index_match .. "}")
22+
end
2523
end
26-
27-
return doc
24+
return inline
2825
end
2926

3027
return {
31-
{
32-
Meta = addIndexEntries,
33-
Pandoc = processDocument
34-
}
28+
{ RawBlock = processBlock, RawInline = processInline }
3529
}

0 commit comments

Comments
 (0)