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/





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

2024-04-29 Thread Michal Hoftich
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/



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

2024-04-28 Thread Nasser M. Abbasi
Follow-up Comment #1, bug #625 (project tex4ht):

I have now a workaround.  So able to build my output.

I changed my program to check the length of each Latex equation generated by
Maple before writing them to the latex file.

If each equation (as string) has length > 10,000 then will not write the whole
Latex generated for that part.

I did not know what is the limit for tex4ht, so picked 10,000.

I found the equation that was causing this bad register code was over 300,000
length.

I know the latex generated by Maple could be better, but that is how it is
generated now.

So I am OK for now. But it will good to know why tex4ht generates this error
and not lualatex. 


Luckily, there are not too many such cases where such huge equations are
generated.

--Nasser

___

Reply to this item at:

  

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



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

2024-04-28 Thread Nasser M. Abbasi
URL:
  

 Summary: Bad register code (65536) again on auto-generated
Latex code
 Project: tex4ht
Submitted by: nma123
Submitted on: Sun Apr 28 23:19:37 2024
Category: None
Priority: 5 - Normal
Severity: 7 - Important
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any

___

Details:


Is there a way to fix this issue? 

(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
No file A.aux.
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/ts1cmr.fd)
! Bad register code (65536).
\__tl_analysis_a_space_test:w ...alysis_index_int 
  {\exp_not:n {
}}\__tl_anal...

l.53 \]


This happens only when using texht.

The Latex is auto-generated by Maple. I know it is due to one or few lines too
long. But it is impossible to edit by hand, since the program generated this
automatically using Maple each time it is run.

Why lualatex handles it OK but not tex4ht? Is there a way to edit some
configuration to make tex4ht not give this error?

Since the equations are large, I put everything in zip file including the
maple style file used.

The command to generate the error is


make4ht -ulm default -a debug A.tex 'mathjax,htm,nostyle'

The zip file is  

https://12000.org/tmp/bad_register_code_tex4ht.zip

When unzipping it will create folder bad_register_code_tex4ht where all the
files are there (A.tex and maple style file).

I am using texlive 2023 on Linux.

I hope there is a solution to this, otherwise I will no longer be able to
build to HTML now.

Thanks
--Nasser






___

Reply to this item at:

  

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