diff options
author | Karl Berry <karl@freefriends.org> | 2024-07-28 20:19:38 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-07-28 20:19:38 +0000 |
commit | 46038932a76eb67e4549242bb4d13783d42ce5e6 (patch) | |
tree | 115e76a35d4b2e168196d05486e6c3defbc7335f /Master/texmf-dist/source/generic | |
parent | c9d59efdb13b67be28531f5922283fb3c7e72376 (diff) |
don't add spaces after LaTeX commands in MathJax, tex4ht r1540
git-svn-id: svn://tug.org/texlive/trunk@71921 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic')
-rw-r--r-- | Master/texmf-dist/source/generic/tex4ht/ChangeLog | 5 | ||||
-rw-r--r-- | Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex | 24 |
2 files changed, 23 insertions, 6 deletions
diff --git a/Master/texmf-dist/source/generic/tex4ht/ChangeLog b/Master/texmf-dist/source/generic/tex4ht/ChangeLog index 26478ea6334..ad1d7c12a7e 100644 --- a/Master/texmf-dist/source/generic/tex4ht/ChangeLog +++ b/Master/texmf-dist/source/generic/tex4ht/ChangeLog @@ -1,3 +1,8 @@ +2024-07-28 Michal Hoftich <michal.h21@gmail.com> + + * tex4ht-mathjax.tex (mathjax-latex-4ht.4ht): don't add spaces after + LaTeX commands. + 2024-07-26 Michal Hoftich <michal.h21@gmail.com> * tex4ht-4ht.tex (tagpdf-hooks.4ht, tagpdf-base-hooks.4ht): removed diff --git a/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex b/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex index 23ca24a586c..25f324ab7fa 100644 --- a/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex +++ b/Master/texmf-dist/source/generic/tex4ht/tex4ht-mathjax.tex @@ -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 @@ 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 \:{ @@ -52,14 +54,24 @@ The original code was this: % % 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 |