Re: [tex4ht] [bug #625] Bad register code (65536) again on auto-generated Latex code

2024-04-30 Thread Michal Hoftich
Hi Nasser,

I think for now, I'll just delete these long equations and
> not write them to the latex file as this seems simplest solution.
>
> Since this is all done in code, I changed my code to check
> for large Latex equations.
>
> Computer algebra systems tend to generate huge Latex expressions.
>

Deletion of the huge equations seems like a good solution because it also
totally breaks your page layout.

Best,
Michal


Re: [tex4ht] [bug #625] Bad register code (65536) again on auto-generated Latex code

2024-04-29 Thread Nasser M. Abbasi

Thanks for the info Michal;

Yes, I changed my texmf.cnf first thing when installing texlive
to increase the counters, else will not be able to compile
most of my files.

cat texmf.cnf 

buf_size=900
pool_size=900
main_memory=900
save_size=100
max_strings = 500
strings_free = 100
hash_extra=1000
stack_size=50


I've also just put the above file in the zip file:



I think for now, I'll just delete these long equations and
not write them to the latex file as this seems simplest solution.

Since this is all done in code, I changed my code to check
for large Latex equations.

Computer algebra systems tend to generate huge Latex expressions.

Regards,
--Nasser



On 4/29/2024 5:32 AM, Michal Hoftich wrote:

Follow-up Comment #2, bug #625 (project tex4ht):

Hi Nasser, this is not limited to TeX4ht but to l3regex, which is used to
clean the MathJax code. See this question, where they found the same issue:
https://tex.stackexchange.com/q/654633/2891

In theory, you could skip the regex cleaning using this configuration file:


\Preamble{xhtml}
\ExplSyntaxOn
\cs_set_protected:Npn \alteqtoks #1
{
   \HCode{\detokenize{#1}}
}
\ExplSyntaxOff
\begin{document}
\EndPreamble
%

The downside is that you can end with incorrect characters in your HTML, in
particular <, > and &. These can cause MathJax fail.

Also, to break your long strings, you can use this prefilter:

%%%
local max_len = 255
for line in io.lines() do
   line = line:gsub("\r", "")
   local str_len = string.len(line)
   if str_len > max_len then
 -- if the line is longer than maxlen, we will break it to a shorter
segments
 local curr_pos = max_len
 local prev_pos = 1
 while curr_pos < str_len do
   -- find next command preceded by spaces starting at the current
position
   curr_pos, len = string.find(line, "%s+\\", curr_pos)
   print(curr_pos, str_len,string.sub(line, prev_pos, curr_pos))
   prev_pos = curr_pos
   -- we must move the current position
   curr_pos = curr_pos + max_len
 end
 -- print rest of the line
 print(string.sub(line, prev_pos, str_len))
   else
 print(line)
   end
end



Use it as:

$ texlua format.lua < original.tex > formated.tex

It will format your long lines into much shorter chunks, preventing the "!
Unable to read an entire line---bufsize=20" error I encountered. I suppose
that you set the limit higher, but I didn't and couldn't compile your file
originally.

 ___

Reply to this item at:

   

___
   Message sent via/by Puszcza
   http://puszcza.gnu.org.ua/