Problem compiling KaTeX

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js, ruby
Domain
tooling

Research direction

Reproduce the failure with Node.js v0.12.1 using the execjs-katex.rb example and compare ExecJS 2.2.2 with 2.4.0. Start with lib/execjs/external_runtime.rb, lib/execjs/runtime.rb, and lib/execjs/module.rb; done means compiling the cited katex.min.js succeeds under the newer version without the undefined global error.

Written by the indexing model from the issue text.

Description

I've been using ExecJS for compiling KaTeX for a while now (see repo https://github.com/drewsberry/jekyll-katex-block).

After upgrading from 2.2.2 (where it worked perfectly), versions 2.3.0 and 2.4.0 cannot compile katex.js, giving the error TypeError: Cannot set property 'katex' of undefined (ExecJS::ProgramError). I downloaded katex.min.js version 0.2.0 from https://github.com/Khan/KaTeX/releases. ExecJS version 2.2.2 compiles the same file without problem.

The full trace is below:

p ((execjs):1:563): TypeError: Cannot set property 'katex' of undefined (ExecJS::ProgramError)
        from (execjs):1:568
        from (execjs):11:14
        from (execjs):1:102
        from Object.<anonymous> ((execjs):1:120)
        from Module._compile (module.js:460:26)
        from Object.Module._extensions..js (module.js:478:10)
        from Module.load (module.js:355:32)
        from Function.Module._load (module.js:310:12)
        from Function.Module.runMain (module.js:501:10)
        from /var/lib/gems/2.1.0/gems/execjs-2.4.0/lib/execjs/external_runtime.rb:32:in `exec'
        from /var/lib/gems/2.1.0/gems/execjs-2.4.0/lib/execjs/external_runtime.rb:14:in `initialize'
        from /var/lib/gems/2.1.0/gems/execjs-2.4.0/lib/execjs/runtime.rb:44:in `new'
        from /var/lib/gems/2.1.0/gems/execjs-2.4.0/lib/execjs/runtime.rb:44:in `compile'
        from /var/lib/gems/2.1.0/gems/execjs-2.4.0/lib/execjs/module.rb:27:in `compile'
        from execjs-katex.rb:4:in `<main>'

It seems like it might have to do with the following line in katex.min.js:

... "undefined" != typeof window ? window.katex = e() : global.katex = e() ...

In 2.2.2, running ExecJS.eval "typeof global" returns Object, whereas in 2.4.0 it returns undefined.

I'm using Node.js v0.12.1 for the runtime.

Dominant language
Ruby
Stars
581
Forks
285
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/execjs

All issues in rails/execjs

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.