Hi Nasser,
Finally I am now able to make MWE that shows this issue and see
> its effect in the HTML.
>
> I use breqn heavily in the code and Michal made a nice
> filter for make4ht which automatically changes all dmath* to
> align* when translating to mathjax. It is called config.lua
> which I put in $HOME/.config/make4ht/config.lua
>
In this case, you can try this version of the build file. It escapes < and
> in Dmath. If you have problems with other math environments, it would
need an update.
Best regards,
Michal
local filter = require "make4ht-filter"
local domfilter = require "make4ht-domfilter"
local function process_options(options)
-- convert [number={foo}] to \tag{foo}
local number = options:match("number%s*=%s*{?(%w+)")
if number then
return "\\tag{" .. number .. "}"
end
return ""
end
local function escape_equal(str)
-- there can be multiple equal characters in the string. we should put the & character
-- just before the one which is not inside any group
-- escape nested equal signs
str = str:gsub("({[^{^}]+)=([^{^}]+})", "%1:EQUAL:%2")
-- replace remaining =
str = str:gsub("([^\n]+)", function(line)
line = line:gsub("=", "&=", 1)
return line .. "\n"
end)
-- str = str:gsub("=", "&=")
-- return escaped =
str = str:gsub(":EQUAL:", "=")
return str
end
local function make_align(dgroup, new_env)
-- change breqn environment contents to align*
-- change = to &=
-- local dgroup = escape_equal(dgroup) -- <- we don't do this anymore, it leads only to problems
local new_env = new_env or "\\begin{align*}\n%s\n\\end{align*}"
dgroup = dgroup:gsub(">", ">"):gsub("<", "<")
-- return the fixed text in align* environment
-- return "\\begin{".. new_env .."}" .. dgroup .. "\\end{" .. new_env .. "}"
return string.format(new_env, dgroup)
end
-- process remaining dmath environments
local function process_dmath(s, env_name, new_env)
return s:gsub("\\begin%s*{" .. env_name .. "}(.-)\\end%s*{" .. env_name .. "}",
function(dmath)
-- options can be still here
local dmath = dmath:gsub("^%s*(%b[])", process_options)
return make_align(dmath, new_env)
end)
end
local function process_dgroup(s, env_name)
return s:gsub("\\begin%s*{" .. env_name .. "}(.-)\\end%s*{" .. env_name .. "}",
function(dgroup)
-- remove environemnts
dgroup = process_dmath(dgroup, "dmath%*", "\n%s\\\\\n")
dgroup = process_dmath(dgroup, "dmath", "\n%s\\\\\n")
local dgroup = escape_equal(dgroup) -- <- we don't do this anymore, it leads only to problems
return make_align(dgroup)
end)
end
local process = filter {
-- find all dgroup* environments and convert them to align*
function(s)
local s = process_dgroup(s,"dgroup%*")
s = process_dgroup(s, "dgroup")
-- process remaining dmath environments in the document
s = process_dmath(s, "dmath%*", "\\[\n%s\n\\]")
s = process_dmath(s, "dmath", "\\begin{equation}\n%s\n \\end{equation}")
return s
end,
}
-- install filter to match HTML files
Make:match("html?$", process)