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

Suggestion to modify the mathjax code [solved] #19

Closed
3 tasks done
sli1989 opened this issue Jan 7, 2018 · 19 comments
Closed
3 tasks done

Suggestion to modify the mathjax code [solved] #19

sli1989 opened this issue Jan 7, 2018 · 19 comments

Comments

@sli1989
Copy link
Collaborator

sli1989 commented Jan 7, 2018

I agree and want to create new issue


Expected behavior

display inline formula using hexo-renderer-pandoc with the mathjax support in the theme's _config.yml.

Actual behavior

  1. using hexo-renderer-marked , and mathjax: enable: true in the theme's _config.yml:
    fail to display all formula;
  2. mathjax: enable: true in the theme's _config.yml, and npm uninstall hexo-renderer-marked --save and Remove the if(config.template) args.push("--template=" + config.template); in hexo\node_modules\hexo-renderer-pandoc\index.js using npm install hexo-renderer-pandoc --save (the known issue):
    fail to display all formula;
  3. mathjax: enable: true in the theme's _config.yml, and npm uninstall hexo-renderer-marked --save and Remove the if(config.template) args.push("--template=" + config.template); in index.js using npm install hexo-renderer-pandoc --save , and try to modify mathjax in /themes/next/source/js/custom.js, and add <script type="text/javascript" src="/js/custom.js"></script> in front of /body in /layout/_layout.swig:
    display inline formula successfully.

the modify in /themes/next/source/js/custom.js is here,
but i don't known how to merge the code in layout/_third-party/mathjax.swig, just a suggestion

//MathJax
window.MathJax = {
    AuthorInit: function () {
      MathJax.Hub.Register.StartupHook("Begin",function () {
        MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for (i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
    });
      });
    }
  };

window.MathJax = {
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true,
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
  };


//  <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
// jQuery
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML', function()
{
    // script is now loaded and executed.
    // put your dependent JS here.
});
  • Link(s) to source code
TESTING inline formula: $R{m \times n} = U{m \times m} S{m \times n} V{n \times n}’$,$d_{1}=\frac{\ln(S_{t}/K)  +(r+\sigma^{2}/2)(T-t)}{\sigma\sqrt{T-t}}$。This is an example for $x_mu$ and $y_mu$. This is an example for $x_{mu}$ and $y_{mu}$.
This is an example for $x\_mu$ and $y\_mu$.
$$
\begin{eqnarray}
\nabla\cdot\vec{E} &=& \frac{\rho}{\epsilon_0} \\
\nabla\cdot\vec{B} &=& 0 \\
\nabla\times\vec{E} &=& -\frac{\partial B}{\partial t} \\
\nabla\times\vec{B} &=& \mu_0\left(\vec{J}+\epsilon_0\frac{\partial E}{\partial t} \right)
\end{eqnarray}
$$
$$T(n) = \Theta(n) + \sum{i=0}^{n-1}{O({n}{i}^2)}$$
$$T(n) = \Theta(n) + \sum_{i=0}^{n-1}{O({n}_{i}^2)}$$
$$T(n) = \Theta(n) + \sum\_{i=0}^{n-1}{O({n}\_{i}^2)}$$

NexT Information

NexT Version:

[x] Latest Master branch.
[x] Latest Release version.
[] Old version -

NexT Scheme:

[] All schemes
[] Muse
[] Mist
[x] Pisces
[] Gemini
@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 8, 2018

As i see u suggest 3rd variant to solve this problem, right?
And u write:

but i don't known how to merge the code in layout/_third-party/mathjax.swig, just a suggestion

So, the simplest way to modify any part of main repo code is:

  1. Do fork of main repo to your remote (and local, but not necessary) repo.
  2. U do any changes in your forked repo, this changes can be made in Github web-interface directly.
  3. After all changes, u create pull request from your remote changed repo to main repo. There will be button named «Pull request» in mainpage of your forked repo:
    image

Try it.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

no... i understand how to pull request, but i don't known how to debug in layout/_third-party/mathjax.swig.
just know how to solve it in next/source/js/custom.js.

@ivan-nginx
Copy link
Member

So, can u step by step write how and where you do changes? And i'll try to do this.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

i will do my best...I'm just a layman in JS.

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 8, 2018

Ok, can u give the path to next/source/js/custom.js file?

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

@ivan-nginx

  1. mathjax: enable: true in the theme's _config.yml,
  2. npm uninstall hexo-renderer-marked --save
  3. npm install hexo-renderer-pandoc --save
  4. Remove the if(config.template) args.push("--template=" + config.template); in hexo\node_modules\hexo-renderer-pandoc\index.js ,
  5. add mathjax in /themes/next/source/js/custom.js:
//MathJax
window.MathJax = {
    AuthorInit: function () {
      MathJax.Hub.Register.StartupHook("Begin",function () {
        MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for (i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
      }
    });
      });
    }
  };

window.MathJax = {
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true,
      skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
  };


//  <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
// jQuery
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML', function()
{
    // script is now loaded and executed.
    // put your dependent JS here.
});
  1. add <script type="text/javascript" src="/js/custom.js"></script> in front of /body in themes/next/layout/_layout.swig:

@ivan-nginx
Copy link
Member

Ok, i see now. I just not understand what is index.js and custom.js. Awaiting for new branch.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

i still have no clue and have given up trying it...
haha

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 8, 2018

Please, try to change in NexT config (latest commit on this changes here):

# MathJax Support
mathjax:
  enable: false
  per_page: false
- cdn: //cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML
+ cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

And of course disable custom.js in _layout.swig.

Still need modify mathjax.swig?


@sli1989 if issue still exists, please:

  1. Make screens with valid and invalid looked formula.
  2. Give this formula in codeblock to explain how i can to paste it to *.md.

If u want see bugfix, i at least must to reproce it. But i don't understand this math things.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

it works, thank u.

# MathJax Support
mathjax:
  enable: true
  per_page: false
  cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

@ivan-nginx
Copy link
Member

ivan-nginx commented Jan 8, 2018

@sli1989 really? Works in 2 variant suggested by u, right?

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

yes, testing in NexT.Muse v6.0.0, there is no need to modify the next/source/js/custom.js and mathjax.swig.
just set the mathjax in the theme's _config.yml.

@ivan-nginx
Copy link
Member

So, this issue is solved?

@ivan-nginx ivan-nginx added Solved and removed Backlog labels Jan 8, 2018
@ivan-nginx ivan-nginx changed the title suggest to modify the mathjax code suggest to modify the mathjax code [need to change CDN to cdn.mathjax.org] Jan 8, 2018
@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

yes, it's done. thank u.

@ivan-nginx
Copy link
Member

Links on MathJax CDN in config was updated: (be3528f)

# MathJax Support
mathjax:
  enable: false
  per_page: false
  # For newMathJax CDN (cdnjs.cloudflare.com) with fallback to oldMathJax (cdn.mathjax.org).
  cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
  # For direct link to MathJax.js with CloudFlare CDN (cdnjs.cloudflare.com).
  #cdn: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML
  # For automatic detect latest varsion link to MathJax.js and get from CloudFlare.
  #cdn: //cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML

@ivan-nginx ivan-nginx changed the title suggest to modify the mathjax code [need to change CDN to cdn.mathjax.org] suggest to modify the mathjax code [need to change mathjax.cdn in NexT config] Jan 8, 2018
@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 8, 2018

😲, suggest to use cdn: //cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML as default,

The MathJax CDN hosted at cdn.mathjax.org will be shutting down on April 30, 2017.

@ivan-nginx
Copy link
Member

I suggest:

  1. Add //cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js as written in docs above.
  2. Add local copy of MathJax as 3rd-party lib extension. For that need to add separated repo.

@sli1989
Copy link
Collaborator Author

sli1989 commented Jan 9, 2018

it's not working with //cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js.
cdn: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML is ok.

@ivan-nginx
Copy link
Member

Ok. Well, need to add local libs with separated repos. I'll do it later, after 6.0.1 release, i think.

@ivan-nginx ivan-nginx added this to the v6.0.2 milestone Jan 9, 2018
@ivan-nginx ivan-nginx changed the title suggest to modify the mathjax code [need to change mathjax.cdn in NexT config] suggest to modify the mathjax code [solved] Mar 4, 2019
@ivan-nginx ivan-nginx changed the title suggest to modify the mathjax code [solved] Suggestion to modify the mathjax code [solved] Apr 1, 2019
@theme-next theme-next locked as resolved and limited conversation to collaborators Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants