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

processEscapes set to true doesn't work #2327

Closed
parhizkari opened this issue Feb 11, 2020 · 11 comments
Closed

processEscapes set to true doesn't work #2327

parhizkari opened this issue Feb 11, 2020 · 11 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3
Milestone

Comments

@parhizkari
Copy link

using version 3.0.1, using "processEscapes" set to "true" stops MathJax from working, giving the error "TypeError: Q.setAttribute is not a function". The folloowing is the minimal example that I tested:

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width">
  <title>MathJax v3 with TeX input and SVG output</title>
  <script>
  MathJax = {
    tex: {
    	inlineMath: [['$', '$']],
    	processEscapes: true
    },
    svg: {fontCache: 'global'}
  };
  </script>
  <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
</head>
<body>
    <h1>MathJax v3 beta: TeX input, HTML output test</h1>

    <p>
    When $a \ne 0$, there are two solutions to $ax^2 + bx + c = 0$ and they are
    $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
    \$equation\$
    </p>
</body>
</html>
@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate labels Feb 12, 2020
@dpvc
Copy link
Member

dpvc commented Feb 12, 2020

I can reproduce the issue and am looking into it. Thanks for the report.

@parhizkari
Copy link
Author

parhizkari commented Feb 12, 2020

Thanks, it was working properly in the previous 3.0.0 version if it helps

@dpvc
Copy link
Member

dpvc commented Feb 13, 2020

It turns out to be the new assistive-mml extension that was causing the problem. I've made a pull request to fix the issue. Thanks for reporting it!

@dpvc
Copy link
Member

dpvc commented Feb 13, 2020

Here is a patch that you can use for now until the next release. Add this to your MathJax configuration:

  MathJax = {
    startup: {
      pageReady() {
        const options = MathJax.startup.document.options;
        const BaseMathItem = options.MathItem;
        options.MathItem = class FixedMathItem extends BaseMathItem {
          assistiveMml(document) {
            if (this.display !== null) super.assistiveMml(document);
          }
        };
        return MathJax.startup.defaultPageReady();
      }
    }
  };

This patches the MathItem class to not do the assistive MathML call if the item is an escaped character.

@parhizkari
Copy link
Author

thanks a lot, it worked ...
I already had ready: function(){...} for introducing Persian digits and defining getAllJax function, adding this new piece of code after that block of code seemingly works with no problem ...

@NicolasCARPi
Copy link

Hello,

I'm also facing this issue. I can confirm that the workaround brings back the typesetting, but a lot of error messages pop up in the console (same with setting processEscapes to false):

2020-02-26-133854_733x227_scrot

Is this expected from the workaround? The input tested can be found here: https://pastebin.com/raw/48veiAsx

Works with 3.0.0 but not 3.0.1. I can also confirm that setting processEscape to false seems to fix the issue (but then we can't have $ anymore).

Thank you @dpvc for providing a workaround AND a fix! :)

Now waiting for next release!

~Nico

PS: congrats and thanks for all the work done for 3.0!

NicolasCARPi added a commit to elabftw/elabftw that referenced this issue Feb 26, 2020
@dpvc
Copy link
Member

dpvc commented Feb 26, 2020

@NicolasCARPi, the error messages you are getting are actually a different issue. The units of mu are specific to TeX, and are supposed to be converted to ems before they are passed to the internal MathML representation. It looks like the extensible arrows (e.g., \xrightarrow) aren't translating these properly. I'll open a separate issue for that.

NicolasCARPi added a commit to elabftw/elabftw that referenced this issue Mar 2, 2020
* hypernext:
  fix the unable to set cookie issue in acceptance tests
  yarn and composer update. also don't throw exception on invalid
  return false instead of throw exception for invalid token_team
  increase sleep for mysql
  fix test login
  fix circleci config for new dev:populate cmd
  add populate-config for phpunit
  use workaround for mathjax/MathJax#2327
  use a yaml config file for dev:populate
  update zipstream
  update js dependencies
  add yarn clean command
  fix default_write to user instead of team
  add datetime on duplicate too
  workaround mysql bug with several current_timestamp columns
  call the version 3.4.0-alpha
  only trigger jsoneditor if needed and target div is here
  probably fix the login issue
  make sure file is an image before looking at exif
@dpvc dpvc added this to the 3.0.2 milestone Mar 5, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Mar 30, 2020
Don't process escaped characters in a11y and menu extensions. mathjax/MathJax#2327.
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Mar 30, 2020
@KyrietS
Copy link

KyrietS commented Apr 5, 2020

@dpvc I know that asciimath is not finished in v3 yet but while your patch fixes the error there is weird behaviour in ascimath. \$ used as masciimath delimiters are not escaped.

jsbin: https://jsbin.com/rokixumiwi/edit?html,output

@dpvc
Copy link
Member

dpvc commented Apr 5, 2020

@KyrietS, The TeX and AsciiMath input jax operate independently, and so the TeX input jax is unaware of the AsciiMath delimiters that you have specified. So both the TeX input jax and AsciiMath input jax think they are to process the \$ (TeX to escape it, and AsciiMath to use it as a delimiter). In fact, both do process it (the a + b in your jsbin is typeset by AsciiMath and the dollar signs around it are processed by TeX).

One solution would be to disable the escape processing of the TeX input jax. Add

processEscapes: false

to the tex section of your configuration to do that.

@KyrietS
Copy link

KyrietS commented Apr 5, 2020

@dpvc Thank you. I apologise for my ignorance. I didn't know that:

docs: the default for processEscapes has changed from false in version 2 to true in version 3.

@dpvc
Copy link
Member

dpvc commented Apr 5, 2020

@KyrietS, no problem.

@dpvc dpvc added the Fixed label Apr 10, 2020
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 Fixed Test Needed v3
Projects
None yet
Development

No branches or pull requests

4 participants