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

Support MathJax #12

Merged
merged 3 commits into from
Jan 21, 2020
Merged

Support MathJax #12

merged 3 commits into from
Jan 21, 2020

Conversation

AtomicVar
Copy link
Contributor

By default, the code tries to use KaTeX. If it is not available, it switches to MathJax.

I tested the code and used it in my blog:

image

image

@AtomicVar AtomicVar mentioned this pull request Apr 29, 2019
@SaswatPadhi
Copy link
Owner

SaswatPadhi commented Jan 5, 2020

Any update on this? I would like to use this too, if MathJax is supported :)

Note that this PR uses the old MathJax 2.x. MathJax 3.0 is now stable; see what's new in 3.0.

@tatetian
Copy link
Collaborator

tatetian commented Jan 6, 2020

Hi guys. I am sorry that I don't have time to maintain this project. If anyone is interested in maintaining this project, I can transfer its ownership.

@SaswatPadhi
Copy link
Owner

Hi @tatetian,

I like this project and can help maintain it. I use MathJax regularly and an algorithm package for it, such as this one, is very useful.

Thanks!

@tatetian
Copy link
Collaborator

tatetian commented Jan 9, 2020

Hi @SaswatPadhi ,

Cool. I am glad that people find this project useful and volunteer to keep developing it. So I will transfer this project under your name. Sounds good?

@SaswatPadhi
Copy link
Owner

Sure, sounds good. Thanks.

@tatetian
Copy link
Collaborator

tatetian commented Jan 9, 2020

Sure, sounds good. Thanks.

I tried to transfer the project to you. But Github reported an error: "SaswatPadhi/pseudocode.js already exists". Could you remove or rename your fork first?

@SaswatPadhi
Copy link
Owner

Oh sorry, right, just removed my fork. I can push my local changes to a new branch once you transfer ownership.

Thanks.

@tatetian
Copy link
Collaborator

Done. Good luck

@tatetian tatetian closed this Jan 13, 2020
@tatetian tatetian reopened this Jan 13, 2020
@SaswatPadhi
Copy link
Owner

Thank you!

@leovan
Copy link
Contributor

leovan commented Jan 18, 2020

Hi @SaswatPadhi , I changed to MathJax v3 recently, it got much faster rendering than before. Is there any plan to support MathJax v3?

@leovan
Copy link
Contributor

leovan commented Jan 19, 2020

Also, I found an easy way but may not a best way to support MathJax v3:

// MathJax
else {
    this._html.putSpan('<span>$' + text + '$</span>');
}

I'm not sure the old API MathJax.HTML.Element("span", null, ["$" + text + "$"]).outerHTML will do something with text or not.

@SaswatPadhi
Copy link
Owner

Hi @leovan,

I am definitely pushing MathJax v3 support within the next few days. I am currently traveling, so didn't have much time to test things locally before pushing. But I will push my changes to this branch directly -- I am building on the MathJax v2 changes proposed by @ZJUGuoShuai.

Also, yes this._html.putSpan('<span>$' + text + '$</span>') is similar to this._html.putSpan(MathJax.HTML.Element("span", null, ["$" + text + "$"]).outerHTML); but notice that the former is creating a raw HTML span element whereas the latter is creating a span with the appropriate content using the MathJax API and then grabbing its outerHTML, i.e. the final serialized HTML code.

As you noticed, the key difference is in how the text is processed. If, for whatever reason, MathJax APIs modify the text before emitting the outerHTML, your approach would miss it, and might break MathJax rendering.

@leovan
Copy link
Contributor

leovan commented Jan 20, 2020

Great, thx @SaswatPadhi

@SaswatPadhi SaswatPadhi merged commit 574122d into SaswatPadhi:master Jan 21, 2020
@leovan
Copy link
Contributor

leovan commented Jan 22, 2020

Hi, @SaswatPadhi , I pull the latest code, but make on macOS results the following error:

pseudocode.js src/Lexer.js src/ParseError.js src/Parser.js src/Renderer.js src/utils.js
make[1]: pseudocode.js: No such file or directory
make[1]: *** [lint] Error 1
make: *** [build/pseudocode.js] Error 2

I do find the pseudocode.js in the root directory, so I don't know what's wrong with it.

@SaswatPadhi
Copy link
Owner

I think you might have deleted the build directory accidentally. I just tried removing that directory, and I get the same error.

Try creating it and then running make again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants