Hexo-theme-next: Not load mathjax per page

Created on 23 Apr 2018  ·  19Comments  ·  Source: theme-next/hexo-theme-next

https://github.com/theme-next/hexo-theme-next/blob/1e8670bed2b4c382e8a0bc5fa8f02fe5044995ed/layout/_third-party/math/index.swig#L13
i think this line should be
{% if theme.math.per_page or (is_index_has_math or page.mathjax) %}

Discussion Solved 🛠 Improvement

Most helpful comment

So, maybe need to rename per_page on something like on_demand?

All 19 comments

U suggest not load MJ per page by default?

https://github.com/theme-next/hexo-theme-next/blob/1e8670bed2b4c382e8a0bc5fa8f02fe5044995ed/_config.yml#L423-L430

@wafer-li, guys, any comments about it?

We had discussed before.
And I prefer to change too.
He seems busy on exam this year.


per page: true mean per page loads math literally. However, If you set it to false, it will load mathjax/katex srcipt EVERY PAGE.

So, maybe need to rename per_page on something like on_demand?

I think it can be done just reverting some logic, but may result in breaking change (can't be compatible).

It's will be breaking change if we change here anything. So, to prevent confuse users rename this option on more comfortable value will be best.

sorry, my next version is a little old, not have this comment ,

Default(true) will load mathjax/katex script on demand
That is it only render those page who has 'mathjax: true' in Front Matter.
if you set it to false, it will load mathjax/katex srcipt EVERY PAGE.

so i think per_page is meaning load every page , so i set this false,
my mathjax cdn is too slow ,mathjax.js also too large( sometimes loading 7-8s ) , making loading totally slow.

a bug for me (when I switch to use the theme from hexo-next repo)

(I am a newbie, just ignore me if this makes no sense)

If I set per_page to true, the hexo-math (using MathJAX) fails to show equations (it shows the latex source.)

I think rename per_page is usefull, such as per_page_manual_control,per_page_on_deand

when per page is set to true, you need to use mathjax:true in each md to enable mathjax.
there should set mathjax tag true in your pages, like this:
image

@StoneMa Ah, I get the meaning of per_page, thanks! To avoid the legacy users, alternatively, you may clarify it in the comments. For example, “when per page is set to true, you need to use mathjax:true in each md to enable mathjax.” Something like this. FYI.

It already had such comments. Excuse me. I will just upgrade my next.

Maybe we can set default value as false, to make sure it works by default.

per_page: false

Just my opinion. It's better if the post file is independent from the theme, or, every time we changes the theme, we need to modify the post file too.

So, is there a mechanism that can detect equation expressions in the post file? Can it be implemented in NexT not Hexo?

So, is there a mechanism that can detect equation expressions in the post file? Can it be implemented in NexT not Hexo?

I think about this too with other guys and for now we can't find something like ready-to-work math autodetection. And actually, this can be implement via internal JS libraries in NexT, but here may be a little trouble: nobody knows, on how much lower will be the speed of content generation then. But idea is nice, thank's for opinion, @panqiincs.


per_page will be true for now in accordance with other sinilar default settings:

https://github.com/theme-next/hexo-theme-next/blob/6051571af94d8dc8684a69603d40f64e307e9593/_config.yml#L449-L455

https://github.com/theme-next/hexo-theme-next/blob/6051571af94d8dc8684a69603d40f64e307e9593/_config.yml#L479-L485

But later we will back to this question again...

So, is there any good way to judge whether there is a math formula in the page? per_page is really a a misleading option, and mathjax: true in front matter is not cool

Need to ask someone who often work math. @sli1989?

yeah, I talked about this last year, and I prefer to change the logic too.
Doing this introduces the breaking change, so this section remain the status quo without necessarily command.

Two different solutions:

My opinion is to keep it as is. Regular expressions are not always accurate (depending on the renderer).
hexo-filter-mathjax plugin added to awesome-next list.

Update: see also https://github.com/next-theme/hexo-filter-mathjax/pull/18

Option renamed in https://github.com/next-theme/hexo-theme-next/commit/a3dcac5f334edddecd3de176175c56d4379a0f21

Was this page helpful?
0 / 5 - 0 ratings