Skip to content

Commit

Permalink
keep braces around index page numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Dec 17, 2024
1 parent baee50f commit adff562
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

- 2024/12/17

- keep track of braces around index entries page numbers.
https://tex.stackexchange.com/a/733106/2891

- 2024/12/08

- support other index locators than index command counters.
Expand Down
18 changes: 9 additions & 9 deletions make4ht-indexing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ end

-- replace numbers in .ind file with links back to text
local function replace_index_pages(rest, entries)
return rest:gsub("%{?(%d+)%}?", function(page)
local entry = entries[tonumber(page)]
if entry then
page = entry.locator or page
-- construct link to the index entry
return "\\Link[" .. entry.file .."]{".. entry.dest .."}{}" .. page .."\\EndLink{}"
else
return page
end
return rest:gsub("(%{?)(%d+)(%}?)", function(lbrace, page, rbrace)
local entry = entries[tonumber(page)]
if entry then
page = entry.locator or page
-- construct link to the index entry
return "{\\Link[" .. entry.file .."]{".. entry.dest .."}{}" .. lbrace .. page .. rbrace .."\\EndLink{}}"
else
return lbrace .. page .. rbrace
end
end)
end

Expand Down

0 comments on commit adff562

Please # to comment.