bugtex4ht - Bugs: bug #625, Bad register code (65536) again on...

 
 
Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

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

Submitted by:  Nasser M. Abbasi <nma123>
Submitted on:  Sun Apr 28 23:19:37 2024  
 
Category: NonePriority: 5 - Normal
Severity: 7 - ImportantStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Mon Apr 29 10:32:57 2024, comment #2:

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=200000" error I encountered. I suppose that you set the limit higher, but I didn't and couldn't compile your file originally.

Michal Hoftich <michal_h21>
Project Member
Mon Apr 29 00:24:37 2024, comment #1:

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

Nasser M. Abbasi <nma123>
Sun Apr 28 23:19:37 2024, original submission:

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

Nasser M. Abbasi <nma123>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by michal_h21 (Posted a comment)
  • -unavailable- added by nma123 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray