[tex4ht-commits] [SCM] tex4ht updated: r796 - trunk/lit

michal_h21 at gnu.org.ua michal_h21 at gnu.org.ua
Sun Sep 13 00:28:43 CEST 2020


Author: michal_h21
Date: 2020-09-13 01:28:43 +0300 (Sun, 13 Sep 2020)
New Revision: 796

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-mathjax.tex
Log:
removed space handling regular expressions in mathjax mode

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2020-09-08 20:01:56 UTC (rev 795)
+++ trunk/lit/ChangeLog	2020-09-12 22:28:43 UTC (rev 796)
@@ -1,3 +1,8 @@
+2020-09-13  Michal Hoftich  <michal.h21 at gmail.com>
+
+	* tex4ht-mathjax.tex (mathjax-latex-4ht.4ht): removed space handling regular
+	expressions, they seem to be unnecessary with current MathJax.
+
 2020-09-08  Michal Hoftich  <michal.h21 at gmail.com>
 
 	* tex4ht-mathml.tex (mathml.4ht): removed some weird code from configuration

Modified: trunk/lit/tex4ht-mathjax.tex
===================================================================
--- trunk/lit/tex4ht-mathjax.tex	2020-09-08 20:01:56 UTC (rev 795)
+++ trunk/lit/tex4ht-mathjax.tex	2020-09-12 22:28:43 UTC (rev 796)
@@ -33,23 +33,30 @@
 \RequirePackage{etoolbox,expl3,environ}
 >>>
 
-The \verb|\alteqtoks| command saves the used command in HTML. It uses regular expressions
-to fix spacing issues introduced by use of the \verb|\detokenize| command.
+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
+after each control sequence. This is completely valid TeX code, but earlier versions of
+MathJax didn't like that, rendering resulted in error.
 
-It works only with LaTeX.
+Fortunatelly, MathJax 3 supports these spaces, so we can remove regular expressions for space handling.
+The original code was this:
 
+% % convert \ { to \:{ 
+% \regex_replace_all:nnN { \x{5C} \x{20} \x{7B} } { \x{5C} \x{3A} \x{7B} } \l_tmpa_tl
+% % delete spaces before left brackets
+% \regex_replace_all:nnN { \x{20} \x{7B} } { \x{7B} } \l_tmpa_tl
+% % 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
+
+
+We still use regula 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:Nx \l_tmpa_tl {\detokenize{#1}}
-  % convert \ { to \:{ 
-  \regex_replace_all:nnN { \x{5C} \x{20} \x{7B} } { \x{5C} \x{3A} \x{7B} } \l_tmpa_tl
-  % delete spaces before left brackets
-  \regex_replace_all:nnN { \x{20} \x{7B} } { \x{7B} } \l_tmpa_tl
-  % 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
-  % replace < > and & with xml entities
+  % % replace < > and & with xml entities
   \regex_replace_all:nnN { \x{26} } { & } \l_tmpa_tl
   \regex_replace_all:nnN { \x{3C} } { < } \l_tmpa_tl 
   \regex_replace_all:nnN { \x{3E} } { > } \l_tmpa_tl



More information about the tex4ht-commits mailing list.