-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_factor.mk4
36 lines (30 loc) · 1.07 KB
/
build_factor.mk4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- https://github.com/michal-h21/tex4ebook/issues/113#issuecomment-1681960392
local domfilter = require "make4ht-domfilter"
local process = domfilter {
function(dom)
for _, image in ipairs(dom:query_selector(".equation img")) do
local src = image:get_attribute("src")
if src then
local m = io.popen("identify -ping -format '%w' " .. src, "r")
local result = m:read("*all")
m:close()
print(result)
-- change this to your liking
-- local factor = 0.9
-- local factor = 0.8
-- local factor = 0.6 -- doesn't shrink x = ax + by + cz noticably.
-- local factor = 0.5
local factor = 0.4
-- local factor = 0.3 -- too small (for \grad F = J in preface)
local newwidth = (tonumber(result) or 0) * factor
if newwidth > 0 then
local style = image:get_attribute(style) or ""
style = style .. string.format("width:%spx;" , newwidth)
image:set_attribute("style", style)
end
end
end
return dom
end
}
Make:match("html$", process)