Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\overbrace broken in SVG output #2402

Closed
dpvc opened this issue Apr 12, 2020 · 9 comments
Closed

\overbrace broken in SVG output #2402

dpvc opened this issue Apr 12, 2020 · 9 comments
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Milestone

Comments

@dpvc
Copy link
Member

dpvc commented Apr 12, 2020

Use of \overbrace causes an error (getVariant not defined). This is due to not passing the variant name to unicodeChars() in the placeChar() method.

See the MathJax User's Forum post.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Ready for Development v3 labels Apr 12, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Apr 13, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Apr 13, 2020
@dainiak
Copy link
Contributor

dainiak commented Apr 14, 2020

"\not\equiv" failed in SVG output in MJ 3.0.5
Is that the same issue there?

@dpvc
Copy link
Member Author

dpvc commented Apr 16, 2020

@dainiak, yes, it is the same issue. You can use

<script>
    MathJax = {
      startup: {
        ready() {
          if (MathJax.version === '3.0.5') {
            const SVGWrapper = MathJax._.output.svg.Wrapper.SVGWrapper;
            const CommonWrapper = SVGWrapper.prototype.__proto__;
            SVGWrapper.prototype.unicodeChars = function (text, variant) {
              if (!variant) variant = this.variant || 'normal';
              return CommonWrapper.unicodeChars.call(this, text, variant);
            }
          }
          MathJax.startup.defaultReady();
        }
      }
    };
</script>

as a work-around until the next release.

dpvc added a commit to mathjax/MathJax-src that referenced this issue May 18, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue May 18, 2020
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels May 26, 2020
@dpvc dpvc added this to the 3.1.0 milestone Aug 25, 2020
@dpvc dpvc added the Fixed label Aug 25, 2020
@dpvc dpvc added v3.1 and removed Merged Merged into develop branch labels Aug 25, 2020
@dpvc
Copy link
Member Author

dpvc commented Aug 25, 2020

Fixed in v3.1 released today.

@FDK7
Copy link

FDK7 commented Feb 15, 2024

Still Problems with svg-Output: Try it on https://mathjax.github.io/MathJax-demos-web/input-tex2svg.html set on renderer: svg with \overbrace{\underbrace{x}\text{real} +\underbrace{iy}\text{imaginary}}^\text{complex number}. In HTML it is fixed.

@dpvc
Copy link
Member Author

dpvc commented Feb 15, 2024

@FDK7, it works for me:

issue2402

Are you still getting an error message?

@FDK7
Copy link

FDK7 commented Feb 15, 2024

grafik
You have to switch to SVG and click display on and off. Loading the website, the renderer seems set to svg, Switching to CHTML and later back to to SVG, you got the result shown in the picture ...

@dpvc
Copy link
Member Author

dpvc commented Feb 15, 2024

You have to switch to SVG and click display on and off.

It is set to SVG initially (and I checked that it was set to that). But if I switch first to CHTML, reload the page, and switch back to SVG, then I see your results.

This is not the same issue as the original, and should have been reported in a new issue (it is never good to add to a closed issue if it is not the same issue). This appears to be related to switching from the initial CHTML renderer to SVG, and since there is some shared data between them, it appears that something is being changed by CHTML that affects the SVG output.

Version 4 (currently in beta release) does not have this issue, so it is fixed in v4, but I'll see if I can figure out what is happening in v3 and provide a work-around.

@dpvc
Copy link
Member Author

dpvc commented Feb 15, 2024

@FDK7, OK, here is a configuration that should resolve the problem in v3:

MathJax = {
  startup: {
    ready() {
      if (MathJax._.output.svg) {
        const {SVGWrapper} = MathJax._.output.svg.Wrapper;
        Object.assign(SVGWrapper.prototype, {
          _unicodeChars: SVGWrapper.prototype.unicodeChars,
          unicodeChars(text, variant = this.variant) {
            text = text.replace(/\\([0-9A-F]{1,4})/g, (match, n) => String.fromCodePoint(parseInt(n, 16)));
            return this._unicodeChars(text, variant);
          }
        });
      }
      MathJax.startup.defaultReady();
    }
  }
};

If you incorporate that into your configuration, that should take care of it.

@dpvc dpvc added the Code Example Contains an illustrative code example, solution, or work-around label Feb 15, 2024
@FDK7
Copy link

FDK7 commented Feb 15, 2024

Great! Included in my electron-app and it is working. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

3 participants