summaryrefslogtreecommitdiff
path: root/support/TeX4ht/source/tex4ht-mathjax.tex
diff options
context:
space:
mode:
Diffstat (limited to 'support/TeX4ht/source/tex4ht-mathjax.tex')
-rw-r--r--support/TeX4ht/source/tex4ht-mathjax.tex33
1 files changed, 28 insertions, 5 deletions
diff --git a/support/TeX4ht/source/tex4ht-mathjax.tex b/support/TeX4ht/source/tex4ht-mathjax.tex
index 23ca24a586..f4338eb6f5 100644
--- a/support/TeX4ht/source/tex4ht-mathjax.tex
+++ b/support/TeX4ht/source/tex4ht-mathjax.tex
@@ -1,4 +1,4 @@
-% $Id: tex4ht-mathjax.tex 1474 2024-02-25 16:27:19Z karl $
+% $Id: tex4ht-mathjax.tex 1553 2024-09-10 13:43:17Z michal_h21 $
% compile: latex tex4ht-mathjax
%
% Copyright 2018-2024 TeX Users Group
@@ -37,12 +37,14 @@ in LaTeX kernel now.
\<required packages\><<<
>>>
-The \verb|\alteqtoks| command saves the used command in HTML. It uses detokenize command
-to insert arguments verbatim. The side effect of this is that detokeize inserts space
+The \verb|\alteqtoks| command prints the used LaTeX math code to the output document in
+verbatim.
+
+In the past, we used \verb|\detokenize|. The side effect of this is that detokeize inserts space
after each control sequence. This is completely valid TeX code, but earlier versions of
MathJax didn't like that, rendering resulted in error.
-Fortunatelly, MathJax 3 supports these spaces, so we can remove regular expressions for space handling.
+Fortunatelly, MathJax 3 supports these spaces, so we could remove regular expressions for space handling.
The original code was this:
% % convert \ { to \:{
@@ -53,7 +55,28 @@ The original code was this:
% \regex_replace_all:nnN { \x{5C} \x{5C} \x{3A} \x{7B} } { \x{5C} \x{5C} \x{20} \x{7B} } \l_tmpa_tl
-We still use regula expressions to escape invalid XML characters to entities, so it works only with LaTeX.
+In July 2024, when I researched another issue, I've found that it is actually possible to avoid these
+extra spaces using LaTeX 3 commands. The inspiration comes from
+\Link[https://tex.stackexchange.com/a/44444/2891]this Bruno Le Foch\EndLink.
+One ongoing issue is that newlines are not presented. But they weren't preserved with \verb|\detokenize|
+either, so it shouldn't be a problem.
+
+In September 2024 I found that the LaTeX 3 method of preserving spaces didn't work correctly for
+code like this: \verb|$\int A f(x)\;dx$| -- the space between \verb|\int| and \verb|A| was removed,
+so it ended like command \verb|\intA|. So we are moving back to \verb|\detokenize|.
+
+This is the code that was promising, but didn't work in the end:
+
+\begin{verbatim}
+ % save tokens, but preserve spaces
+ % https://tex.stackexchange.com/a/44444/2891
+ \tl_set:Nn \l_tmpa_tl {#1}
+ \regex_replace_all:nnN { . } { \c{string} \0 } \l_tmpa_tl
+ \tl_set:Nx \l_tmpa_tl { \l_tmpa_tl }
+\end{verbatim}
+
+
+We still use regular expressions to escape invalid XML characters to entities, so it works only with LaTeX.
\<defined commands\><<<
\ExplSyntaxOn