summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-03-03 21:32:09 +0000
committerKarl Berry <karl@freefriends.org>2023-03-03 21:32:09 +0000
commit0fb6686a392b4ff23b4e40595b22119105fdc13a (patch)
tree102c1e6bc2972b6be4ca61d8d063857033b4a9d3 /Master/texmf-dist/scripts
parent54edef3568ebd2314ba3ee15176b5c2819fab6df (diff)
tex4ebook (3mar23)
git-svn-id: svn://tug.org/texlive/trunk@66332 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/tex4ebook9
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua49
-rwxr-xr-xMaster/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua4
3 files changed, 41 insertions, 21 deletions
diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook b/Master/texmf-dist/scripts/tex4ebook/tex4ebook
index 8f6c8aa3f73..0bde98c9e0c 100755
--- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook
+++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook
@@ -43,7 +43,7 @@ tex4ebook [switches] filename ["tex4ht.sty op."] ["tex4ht op."] ["t4ht op"] ["la
-j,--jobname (default nil) Set the jobname
-l,--lua Use lualatex for document compilation
-m,--mode (default default) Switch which can be used in the makefile
- -r,--resolution (default 167)
+ -r,--resolution (default nil) This option is obsolete, use build files instead!
-s,--shell-escape Enable shell escape in htlatex run
-t,--tidy Run html tidy on html output. May result in wrong spacing!
-x,--xetex Use xelatex for document compilation
@@ -67,7 +67,7 @@ else
end
if args.version then
- print "tex4ebook v0.3h"
+ print "tex4ebook v0.3i"
return
end
@@ -150,6 +150,11 @@ local oldparams = {
,packages="\\RequirePackage{tex4ebook}"
}
+if oldparams.resolution~="nil" then
+ log:warning("The resolution parameter is deprecated. Please use a build file")
+ log:warning("See information about Make:image() command in Make4ht documenation")
+end
+
-- extend params
for k,v in pairs(oldparams) do
params[k] = v
diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua
index 539cf930ab6..539e9b19ba9 100755
--- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua
+++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub.lua
@@ -127,49 +127,63 @@ local mimetypes = {
css = "text/css",
png = "image/png",
jpg = "image/jpeg",
+ jpeg = "image/jpeg",
gif = "image/gif",
svg = "image/svg+xml",
html= "application/xhtml+xml",
xhtml= "application/xhtml+xml",
ncx = "application/x-dtbncx+xml",
- otf = "application/opentype",
- ttf = "application/truetype",
+ otf = "application/font-sfnt",
+ ttf = "application/font-sfnt",
woff = "application/font-woff",
+ woff2 = "font/woff2",
js = "text/javascript",
mp3 = "audio/mpeg",
- smil = "application/smil+xml"
+ mp4 = "audio/mp4",
+ avi = "video/x-msvideo",
+ mkv = "video/x-matroska",
+ smil = "application/smil+xml",
+ pls = "application/pls+xml"
}
function remove_empty_guide(content)
return content:gsub("<guide>%s*</guide>","")
end
+
+
function make_opf()
-- Join files content.opf and content-part2.opf
-- make item record for every converted image
local lg_item = function(item)
-- Find mimetype and make item tag for each converted file in the lg file
- local fname,ext = item:match("([%a%d%_%-]*)%p([%a%d]*)$")
- local mimetype = mimetypes[ext] or ""
- if mimetype == "" then log:info("Mimetype for "..ext.." is not registered"); return nil end
+ local fname,ext = item:match("([^%/^%.]*)%.([%a%d]*)$")
+ if not ext then return nil end
+ local lower_ext = string.lower(ext)
+ local mimetype = mimetypes[lower_ext] or ""
+ if mimetype == "" then log:info("Mimetype for the "..ext.." extension is not registered"); return nil end
local dir_part = item:split("/")
table.remove(dir_part,#dir_part)
local id=table.concat(dir_part,"-")..fname.."_"..ext
-- remove invalid characters from id start
id = id:gsub("^[%.%-]*","")
-- remove colons
- id = id:gsub(":", "_")
+ id = id:gsub("[:%(%)]", "_")
-- id cannot start by number, add trailing "x" character
id = id:gsub("^([%d])", "x%1")
return "<item id='"..id .. "' href='"..item.."' media-type='"..mimetype.."' />",id
end
local find_all_files= function(s,r)
- local r = r or "([%a%d%_%-]*)%.([x]?html)"
+ -- find files that had been declared in the OPF file using \Configure{OpfMetadata}
+ local r = r or "(.*)%.([x]?html)"
local files = {}
- for i, ext in s:gmatch(r) do
- --local i, ext = s:match(r)-- do
- ext = ext or "true"
- files[i] = ext
+ for item in s:gmatch("href=\"(.-)\"") do
+ local i, ext = item:match(r)
+ if i then
+ --local i, ext = s:match(r)-- do
+ ext = ext or "true"
+ files[item] = ext
+ end
end
return files
end
@@ -188,7 +202,8 @@ function make_opf()
local h_second = io.open(opf_second_part,"r")
local opf_complete = {}
table.insert(opf_complete,h_first:read("*all"))
- local used_html = find_all_files(opf_complete[1])
+ -- we used to detect all declared HTML files, but this table wasn't used anymore, so I deprecate this use
+ -- local used_html = find_all_files(opf_complete[1])
-- local lg_file = ebookutils.parse_lg(outputfilename..".lg")
-- The lg_file has been already loaded by make4ht, it doesn't make sense to load it again
-- Furthermore, it is now possible to add new files from Lua build files
@@ -196,12 +211,10 @@ function make_opf()
local used_files = {}
for _,filename in ipairs(lg_file["files"]) do
-- we need to test the filenames in order to prevent duplicates
- -- filenames are tested without paths, so there may be issues if
- -- the same filename is used in different directories. Is that a problem?
used_files[filename] = true
end
local outside_spine = {}
- local all_used_files = find_all_files(opf_complete[1],"([%a%d%-%_]+%.[%a%d]+)")
+ local all_used_files = find_all_files(opf_complete[1],"(.+)%.(.+)")
local used_paths = {}
local used_ids = {}
for _,k in ipairs(lg_file["files"]) do
@@ -212,8 +225,6 @@ function make_opf()
table.remove(parts,#parts)
--table.insert(parts,1,"OEBPS")
table.insert(parts,1,outputdir)
- -- print("SSSSS "..fn.." ext .." .. ext)
- --if string.find("jpg gif png", ext) and not all_used_files[k] then
local item,id = lg_item(k)
if item then
local path = table.concat(parts)
@@ -232,7 +243,7 @@ function make_opf()
end
if not used_ids[id] then
ebookutils.copy(k, outputdir .. "/"..k)
- if not all_used_files[fn] then
+ if not all_used_files[k] then
table.insert(opf_complete,item)
if allow_in_spine[ext] then
table.insert(outside_spine,id)
diff --git a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
index 328acaae375..bf66548e2cd 100755
--- a/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
+++ b/Master/texmf-dist/scripts/tex4ebook/tex4ebook-exec_epub3.lua
@@ -186,6 +186,10 @@ local function cleanTOC(content)
if filename then
filename = outputdir .. "/" .. filename
local f = io.open(filename, "r")
+ if not f then
+ log:warning("Cannot open TOC file for clean-up: " .. filename)
+ return nil
+ end
local t = f:read("*all")
f:close()
local tocdom = dom.parse(t)