-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore numbers in braces in indexing
- Loading branch information
1 parent
3c8af19
commit 3f1bc8d
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
local mkutils = require "mkutils" | ||
local zip = require "zip" | ||
|
||
|
||
-- use function to change contents of the ODT file | ||
local function update_odt(odtfilename, file_path, fn) | ||
-- get name of the odt file | ||
local odtname = mkutils.remove_extension(odtfilename) .. ".odt" | ||
-- open and read contents of the requested file inside ODT file | ||
local odtfile = zip.open(odtname) | ||
local local_file = odtfile:open(file_path) | ||
local content = local_file:read("*all") | ||
local_file:close() | ||
odtfile:close() | ||
-- update the content using user function | ||
content = fn(content) | ||
-- write the updated file | ||
local local_file_file = io.open(file_path,"w") | ||
local_file_file:write(content) | ||
local_file_file:close() | ||
os.execute("zip " .. odtname .. " " .. file_path) | ||
os.remove(file_path) | ||
end | ||
|
||
Make:match("tmp$", function(name, par) | ||
update_odt(name, "content.xml", function(content) | ||
return content:gsub("%&%#x([A-Fa-f0-9]+);", function(entity) | ||
-- convert hexadecimal entity to Unicode | ||
print(entity,utfchar(tonumber(entity, 16))) | ||
return utfchar(tonumber(entity, 16)) | ||
end) | ||
end) | ||
end) |