texlive[71921] Master/texmf-dist: don't add spaces after LaTeX
commits+karl at tug.org
commits+karl at tug.org
Sun Jul 28 22:19:39 CEST 2024
Revision: 71921
https://tug.org/svn/texlive?view=revision&revision=71921
Author: karl
Date: 2024-07-28 22:19:38 +0200 (Sun, 28 Jul 2024)
Log Message:
-----------
don't add spaces after LaTeX commands in MathJax, tex4ht r1540
Revision Links:
--------------
https://tug.org/svn/texlive?view=revision&revision=1540
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-07-28 20:11:05 UTC (rev 71920)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/ChangeLog 2024-07-28 20:19:38 UTC (rev 71921)
@@ -1,3 +1,8 @@
+2024-07-28 Michal Hoftich <michal.h21 at gmail.com>
+
+ * tex4ht-mathjax.tex (mathjax-latex-4ht.4ht): don't add spaces after
+ LaTeX commands.
+
2024-07-26 Michal Hoftich <michal.h21 at gmail.com>
* tex4ht-4ht.tex (tagpdf-hooks.4ht, tagpdf-base-hooks.4ht): removed
Modified: trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex
===================================================================
--- trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex 2024-07-28 20:11:05 UTC (rev 71920)
+++ trunk/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex 2024-07-28 20:19:38 UTC (rev 71921)
@@ -1,4 +1,4 @@
-% $Id: tex4ht-mathjax.tex 1474 2024-02-25 16:27:19Z karl $
+% $Id: tex4ht-mathjax.tex 1540 2024-07-28 17:10:17Z michal_h21 $
% compile: latex tex4ht-mathjax
%
% Copyright 2018-2024 TeX Users Group
@@ -37,12 +37,14 @@
\<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 \:{
@@ -52,14 +54,24 @@
% % 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
+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.
-We still use regula expressions to escape invalid XML characters to entities, so it works only with LaTeX.
+We still use regular expressions to escape invalid XML characters to entities, so it works only with LaTeX.
+
\<defined commands\><<<
\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
- \tl_set:Ne \l_tmpa_tl {\detokenize{#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 }
% % 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-07-28 20:11:05 UTC (rev 71920)
+++ trunk/Master/texmf-dist/tex/generic/tex4ht/mathjax-latex-4ht.4ht 2024-07-28 20:19:38 UTC (rev 71921)
@@ -1,4 +1,4 @@
-% mathjax-latex-4ht.4ht (2024-02-25-08:28), generated from tex4ht-mathjax.tex
+% mathjax-latex-4ht.4ht (2024-07-28-13:12), generated from tex4ht-mathjax.tex
% Copyright 2018-2024 TeX Users Group
%
% This work may be distributed and/or modified under the
@@ -5,7 +5,7 @@
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
-% http://www.latex-project.org/lppl.txt
+% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
@@ -12,17 +12,21 @@
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
-% is the TeX4ht Project <http://tug.org/tex4ht>.
+% is the TeX4ht Project <https://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
-\immediate\write-1{version 2024-02-25-08:28}
+\immediate\write-1{version 2024-07-28-13:12}
\ExplSyntaxOn
\cs_new_protected:Npn \alteqtoks #1
{
- \tl_set:Ne \l_tmpa_tl {\detokenize{#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 }
% % replace < > and & with xml entities
\regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
\regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl
@@ -217,6 +221,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
More information about the tex-live-commits
mailing list.