@@ -100,7 +100,11 @@ local function replace_index_pages(rest, entries)
100
100
-- keep track of the previous page number
101
101
local count = 0
102
102
local delete_coma = false
103
- return rest :gsub (" (%s*%-*%s*)(,?%s*)(%{?)(%d+)(%}?)" , function (dash , coma , lbrace , page , rbrace )
103
+ return rest :gsub (" (%s*%-*%s*)(,?%s*)(%{?)(%[?)(%d+)(%]?)(%}?)" , function (dash , coma , lbrace , lbracket , page , rbracket , rbrace )
104
+ if lbracket == " [" and rbracket == " ]" then
105
+ -- don't process numbers in brackets, they are not page numbers
106
+ return nil
107
+ end
104
108
local entry = entries [tonumber (page )]
105
109
count = count + 1
106
110
if entry then
@@ -128,7 +132,7 @@ local function replace_index_pages(rest, entries)
128
132
return dash .. coma .. lbrace .. " \\ Link[" .. entry .file .. " ]{" .. entry .dest .. " }{}" .. page .. " \\ EndLink{}" .. rbrace
129
133
end
130
134
else
131
- return dash .. coma .. lbrace .. page .. rbrace
135
+ return dash .. coma .. lbrace .. lbracket .. page .. rbracket .. rbrace
132
136
end
133
137
end )
134
138
end
@@ -139,7 +143,7 @@ local fix_idx_pages = function(content, idxobj)
139
143
local buffer = {}
140
144
local entries = idxobj .map
141
145
for line in content :gmatch (" ([^\n ]+)" ) do
142
- local line , count = line :gsub (" (%s*\\ %a+.-%, )(.+)$" , function (start ,rest )
146
+ local line , count = line :gsub (" (%s*\\ %a+[^%[^,]+ )(.+)$" , function (start ,rest )
143
147
-- reset the previous page number
144
148
previous = nil
145
149
-- there is a problem when index term itself contains numbers, like Bible verses (1:2),
0 commit comments