Subject: bug#27259: 26.0.50; 26.0.50: EWW displays LaTeX formulas as extemely large

From: [email-masked] (Charles A. Roelli)
Date: Tue, 05 Sep 2017 21:35:04 +0200

> Authentication-Results: sinyavsky.aurox.ch (amavisd-new); 	dkim=pass (2048-bit key) header.d=triply-cc.20150623.gappssmtp.com
> From: Wouter Beek <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 31 Aug 2017 21:40:58 +0200
> Content-Type: text/plain
> 
> [email-masked] (Charles A. Roelli) writes:
> 
> >> From: Wouter Beek <[email-masked]>
> >> Date: Mon, 05 Jun 2017 22:04:41 +0200
> >> 
> >> 1. M-x eww
> >> 2. https://en.wikipedia.org/wiki/Triangular_number RET
> >> 3. Scroll down the page to an enormously large LaTeX formula.
> >> 
> >> In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
> >>  of 2017-06-02 built on laptop
> >> Repository revision: f0d79d2b8d3a8a0b2aa7b39519d1df32f0e335e6
> >> Windowing system distributor 'The X.Org Foundation', version 11.0.11903000
> >> System Description:	Ubuntu 17.04
> >
> > I can't reproduce it (using master under macOS).  Does the problem
> > still occur for you?
> 
> Thanks for looking into this!  When I visit the same web page in EWW,
> Emacs version 25.2.1 (I moved back to using stable releases), I do not
> see a formula at all.  Since this issue is better explained in a
> picture, I have uploaded a screenshot of this:
> http://wouterbeek.github.io/img/eww.png

Thanks for the screenshot.  It looks like the problematic HTML is this
(the source code for the TeX formula):

<span class="mwe-math-element"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" >
  <semantics>
    <mrow class="MJX-TeXAtom-ORD">
      <mstyle displaystyle="true" scriptlevel="0">
        <msub>
          <mi>T</mi>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>n</mi>
          </mrow>
        </msub>
        <mo>=</mo>
        <munderover>
          <mo>&#x2211;<!-- ∑ --></mo>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>k</mi>
            <mo>=</mo>
            <mn>1</mn>
          </mrow>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>n</mi>
          </mrow>
        </munderover>
        <mi>k</mi>
        <mo>=</mo>
        <mn>1</mn>
        <mo>+</mo>
        <mn>2</mn>
        <mo>+</mo>
        <mn>3</mn>
        <mo>+</mo>
        <mo>&#x22EF;<!-- ⋯ --></mo>
        <mo>+</mo>
        <mi>n</mi>
        <mo>=</mo>
        <mrow class="MJX-TeXAtom-ORD">
          <mfrac>
            <mrow>
              <mi>n</mi>
              <mo stretchy="false">(</mo>
              <mi>n</mi>
              <mo>+</mo>
              <mn>1</mn>
              <mo stretchy="false">)</mo>
            </mrow>
            <mn>2</mn>
          </mfrac>
        </mrow>
        <mo>=</mo>
        <mrow class="MJX-TeXAtom-ORD">
          <mrow>
            <mrow class="MJX-TeXAtom-OPEN">
              <mo maxsize="2.047em" minsize="2.047em">(</mo>
            </mrow>
            <mfrac linethickness="0">
              <mrow>
                <mi>n</mi>
                <mo>+</mo>
                <mn>1</mn>
              </mrow>
              <mn>2</mn>
            </mfrac>
            <mrow class="MJX-TeXAtom-CLOSE">
              <mo maxsize="2.047em" minsize="2.047em">)</mo>
            </mrow>
          </mrow>
        </mrow>
        <mo>,</mo>
      </mstyle>
    </mrow>
    <annotation encoding="application/x-tex">{\displaystyle T_{n}=\sum _{k=1}^{n}k=1+2+3+\dotsb +n={\frac {n(n+1)}{2}}={n+1 \choose 2},}</annotation>
  </semantics>
</math></span><img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/8411fe69f79f2971b7c7a453b0b547bb37e9f6df" class="mwe-math-fallback-image-inline" aria-hidden="true" style="vertical-align: -3.171ex; width:58.093ex; height:7.176ex;" alt="{\displaystyle T_{n}=\sum _{k=1}^{n}k=1+2+3+\dotsb +n={\frac {n(n+1)}{2}}={n+1 \choose 2},}" /></span>

I doubt we support the code between the <math> tags, so I think what
/should/ show up is the "fallback" SVG image that Wikipedia provides:

<img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/8411fe69f79f2971b7c7a453b0b547bb37e9f6df" .../>

Please experiment with SVG files (such as the one above) to check if
they all have this rendering issue in Emacs.

Thanks in advance.