bug-texinfo
[Top][All Lists]

## Re: behavior of @math with HTML output

 From: Vincent Lefevre Subject: Re: behavior of @math with HTML output Date: Thu, 13 Oct 2022 11:57:26 +0200 User-agent: Mutt/2.2.7+47 (8681885b) vl-149028 (2022-10-10)

On 2022-10-13 06:48:49 +0100, Gavin Smith wrote:
> This is the default if MathJax is not turned on or tex4ht or latex2html
> are not used.  The <em> tag marks the text as separate.  There is not
> much more that could be done - texi2any does not itself interpret
> TeX math notation at all and is not going to format e.g. digits
> differently.
>
> My advice is to use MathJax when generating the manual as described in
> the same part of the manual.

The GMP manual has the following:

@c  @m{T,N} is $T$ in tex or @math{N} otherwise.  Commas in N or T don't work,
@c  but @C{} can be used instead.
@iftex
@macro m {T,N}
@tex$\T\$@end tex
@end macro
@end iftex
@ifnottex
@macro m {T,N}
@math{\N\}
@end macro
@end ifnottex

with for instance a use like that:

Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
@var{op2}}.

So, if a PDF is generated, then TeX is used and everything is OK, but
if HTML is generated, then one gets something like

@math{@var{op1} times 2 raised to @var{op2}}

so MathJax would not make much sense on that. And since this is like
normal text, I don't see why <em> makes sense.

BTW, 16440098c6229e38fa6ecc32a07c0a099491815a:texinfo/doc/texinfo.txi
(which was the initial revision, in 2002) says

@noindent which looks like the input in Info and HTML:
@example
\sin 2\pi \equiv \cos 3\pi
@end example

so it appears that Info and HTML were treated in the same way.

FYI, what was added in 2000 in GMP:

[...]
+@c  @m{T,N} is $T$ in tex or @math{N} otherwise.  This is an easy way to give
+@c  different forms for math in tex and info.  Commas in N or T don't work,
+@c  but @C{} can be used instead.  \, works in info but not in tex.
+@iftex
+@macro m {T,N}
+@tex$\T\$@end tex
+@end macro
+@end iftex
+@ifnottex
+@macro m {T,N}
+@math{\N\}
+@end macro
+@end ifnottex
[...]
@deftypefun void mpz_mul_2exp (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long
int @var{op2})
@cindex Bit shift left
-@ifnottex
-Set @var{rop} to @var{op1} times 2 raised to @var{op2}.  This operation can
-also be defined as a left shift, @var{op2} steps.
-@end ifnottex
-@tex
-Set @var{rop} to $@var{op1} \times 2^{op2}$.  This operation can also be
-defined as a left shift, @var{op2} steps.
-@end tex
+Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
+@var{op2}}.  This operation can also be defined as a left shift by @var{op2}
+bits.
@end deftypefun
[...]

In any case, if one goes back to the texinfo example

\sin 2\pi \equiv \cos 3\pi

a better treatment for HTML would be to replace \xxx by the Unicode
character when it exists (there could be a table for that), and the
other backslashes could be removed in the output. So one would get

sin 2π ≡ cos 3π

and I still see no reasons to use <em> on this. I would rather see
a <span class="math"> so that there would be no special styles by
default (like for Info), but CSS could optionally be added.

--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)