texlive[72251] Master/texmf-dist: \detokenize for mathjax, tex4ht
commits+karl at tug.org
commits+karl at tug.org
Tue Sep 10 23:21:01 CEST 2024
Revision: 72251
https://tug.org/svn/texlive?view=revision&revision=72251
Author: karl
Date: 2024-09-10 23:21:01 +0200 (Tue, 10 Sep 2024)
Log Message:
-----------
\detokenize for mathjax, tex4ht r1553
Revision Links:
--------------
https://tug.org/svn/texlive?view=revision&revision=1553
Modified Paths:
--------------
trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex
trunk/Master/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht
Modified: trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog 2024-09-10 20:12:36 UTC (rev 72250)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog 2024-09-10 21:21:01 UTC (rev 72251)
@@ -1,3 +1,9 @@
+2024-09-10 Michal Hoftich <michal.h21 at gmail.com>
+
+ * tex4ht-mathjax.tex (mathjax-latex-4ht.4ht): use \detokenize again,
+ the alternative method could lead to commands joined with the
+ following text (\int A to \intA).
+
2024-09-09 Michal Hoftich <michal.h21 at gmail.com>
* tex4ht-4ht.tex (usepackage.4ht, enumitem-hooks.4ht, enumitem.4ht),
Modified: trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex 2024-09-10 20:12:36 UTC (rev 72250)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex 2024-09-10 21:21:01 UTC (rev 72251)
@@ -1,4 +1,4 @@
-% $Id: tex4ht-mathjax.tex 1540 2024-07-28 17:10:17Z michal_h21 $
+% $Id: tex4ht-mathjax.tex 1553 2024-09-10 13:43:17Z michal_h21 $
% compile: latex tex4ht-mathjax
%
% Copyright 2018-2024 TeX Users Group
@@ -54,13 +54,28 @@
% % replace \\:{ back to \\ { -- this can be introduced by the previous regex
% \regex_replace_all:nnN { \x{5C} \x{5C} \x{3A} \x{7B} } { \x{5C} \x{5C} \x{20} \x{7B} } \l_tmpa_tl
-Now (July 2024), when I researched another issue, I've found that it is actually possible to avoid these
+
+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\><<<
@@ -67,11 +82,7 @@
\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
- % 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 }
+ \tl_set:Ne \l_tmpa_tl {\detokenize{#1}}
% % replace < > and & with xml entities
\regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
\regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl
Modified: trunk/Master/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht
===================================================================
--- trunk/Master/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht 2024-09-10 20:12:36 UTC (rev 72250)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht 2024-09-10 21:21:01 UTC (rev 72251)
@@ -1,4 +1,4 @@
-% mathjax-latex-4ht.4ht (2024-07-28-13:12), generated from tex4ht-mathjax.tex
+% mathjax-latex-4ht.4ht (2024-09-10-13:45), generated from tex4ht-mathjax.tex
% Copyright 2018-2024 TeX Users Group
%
% This work may be distributed and/or modified under the
@@ -16,17 +16,13 @@
%
% If you modify this program, changing the
% version identification would be appreciated.
-\immediate\write-1{version 2024-07-28-13:12}
+\immediate\write-1{version 2024-09-10-13:45}
\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
- % 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 }
+ \tl_set:Ne \l_tmpa_tl {\detokenize{#1}}
% % replace < > and & with xml entities
\regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
\regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl
@@ -221,6 +217,10 @@
+
+
+
+
More information about the tex-live-commits
mailing list.