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 v3 #1221

Merged
merged 6 commits into from
Mar 1, 2020
Merged

Support MathJaX v3 #1221

merged 6 commits into from
Mar 1, 2020

Conversation

tani
Copy link
Contributor

@tani tani commented Feb 24, 2020

First of all, I like this awesome software!
As I'd like to use MathJaX v3 in VNote, I updated it. MathJaX v3 have a new plugin for bussproofs missing in the older versions. But I'm sorry for that I cloud not build this software in my local environment (ubuntu 18.04 and Qt5.9). While I finally didn't know why I could not build, I guess I can improve your software with this request. Could you test in your environment?

@tani tani requested a review from tamlok February 24, 2020 09:28
@@ -14,7 +14,7 @@ if (typeof VPlantUMLServer == 'undefined') {
}

new QWebChannel(qt.webChannelTransport,
function(channel) {
function (channel) {
Copy link
Member

@tamlok tamlok Feb 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please revert all these style changes, which makes the PR a mess. Thank you for your PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I formatted it.

@@ -10,7 +10,7 @@
<link rel="stylesheet" type="text/css" href="CSS_PLACE_HOLDER">
<script src="qrc:/resources/qwebchannel.js"></script>
<!-- EXTRA_PLACE_HOLDER -->
<script src="JS_PLACE_HOLDER" async></script>
<script src="JS_PLACE_HOLDER" async id="MathJax-script"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MathJax v3 refers the <script> itself because MathJaX loads some plugin dynamically by need, e.g., fonts, stylesheet. See also, http://docs.mathjax.org/en/latest/web/start.html#using-mathjax-from-a-content-delivery-network-cdn

@@ -36,6 +36,47 @@ var isEmptyMathJax = function(text) {
return text.replace(/\$/g, '').trim().length == 0;
};

// MathJax v3 compat (http://docs.mathjax.org/en/latest/upgrading/v2.html#v2-compatibility-example)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just modify the preview stuff. MathJax is also used in the read mode, like markdown-it.js and markdown-template.js. Do we need to change code in those places?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I added this snippet to them.

@tani
Copy link
Contributor Author

tani commented Feb 25, 2020

I success to build this project in my local environment but it does not render equations correctly.
I notice that MathJaX v3 does not have resetEquationNumbers API. Even if I deleted this API in code, it still does not render correctly. In my sense, the way to use compatibility layer is totally bad way to use MathJaX v3. Thus, we should redesign to use MathJaX's new API but I give up because your project is too large to read in a week. I'm sorry.

Now, it worked!!! Could you give me a day? I cleanup this PR.

@tamlok
Copy link
Member

tamlok commented Feb 25, 2020

Go ahead and take your time. :)

@tani
Copy link
Contributor Author

tani commented Feb 26, 2020

Everything works fine even if markdown-it, showdown, hoedown, and marked. Could you check them again?

@tamlok
Copy link
Member

tamlok commented Feb 29, 2020

Great work! There is one minor issue: when preview, the font size of the previewed formula is too small in a 4K display. Where could I put a scale factor in the config of the preview script? VNote will detect the real scale factor of the display.

image

@tani
Copy link
Contributor Author

tani commented Feb 29, 2020

I added scale option in mathjax_preview_template.html.
I guess you will add the placeholder like JS_PLACE_HOLDER in https://github.com/bibliobibulus/vnote/blob/eea2ecd14d7c5ce1bbdd310fe7a9bcbe2f3e0484/src/resources/mathjax_preview_template.html#L13-L23 . Thus, you can set a scale factor.

@tamlok
Copy link
Member

tamlok commented Feb 29, 2020

Is cthml a typo?

@tani
Copy link
Contributor Author

tani commented Feb 29, 2020

Oops, yes :p

@tamlok tamlok merged commit 5df695c into vnotex:master Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants