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

Fix #553 New Feature: mhchem support #554

Merged
merged 2 commits into from
Dec 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cache:
# And if you want to place your icons in `hexo-site/source/` root directory, you must remove `/images` prefix from pathes.

# For example, you put your favicons into `hexo-site/source/images` directory.
# Then need to rename & redefine they on any other names, otherwise icons from Next will rewrite your custom icons in Hexo.
# Then need to rename & redefine them on any other names, otherwise icons from Next will rewrite your custom icons in Hexo.
favicon:
small: /images/favicon-16x16-next.png
medium: /images/favicon-32x32-next.png
Expand All @@ -64,15 +64,15 @@ footer:

# Icon between year and copyright info.
icon:
# Icon name in fontawesome, see: https://fontawesome.com/v4.7.0/icons
# Icon name in fontawesome, see: https://fontawesome.com/v4.7.0/icons/
# `heart` is recommended with animation in red (#ff0000).
name: user
# If you want to animate the icon, set it to true.
animated: false
# Change the color of icon, using Hex Code.
color: "#808080"

# If not defined, will be used `author` from Hexo main config.
# If not defined, `author` from Hexo main config will be used.
copyright:
# -------------------------------------------------------------
powered:
Expand All @@ -99,7 +99,7 @@ footer:

# Creative Commons 4.0 International License.
# https://creativecommons.org/share-your-work/licensing-types-examples
# Available: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero
# Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero
creative_commons:
license: by-nc-sa
sidebar: false
Expand Down Expand Up @@ -135,7 +135,7 @@ exturl: false
# Key is the name of menu item. If translate for this menu will find in languages - this translate will be loaded; if not - Key name will be used. Key is case-senstive.
# Value before `||` delimeter is the target link.
# Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, question icon will be loaded.
# External url should start with http:// or https:// .
# External url should start with http:// or https://
menu:
home: / || home
#about: /about/ || user
Expand Down Expand Up @@ -170,7 +170,7 @@ scheme: Muse
# Posts / Categories / Tags in sidebar.
site_state: true

# Social Links.
# Social Links
# Usage: `Key: permalink || icon`
# Key is the link label showing to end users.
# Value before `||` delimeter is the target permalink.
Expand Down Expand Up @@ -231,7 +231,7 @@ toc:
max_depth: 6

sidebar:
# Sidebar Position, available value: left | right (only for Pisces | Gemini).
# Sidebar Position, available values: left | right (only for Pisces | Gemini).
position: left
#position: right

Expand All @@ -241,7 +241,7 @@ sidebar:
# Pisces | Gemini: 240
#width: 300

# Sidebar Display, available value (only for Muse | Mist):
# Sidebar Display, available values (only for Muse | Mist):
# - post expand on posts automatically. Default.
# - always expand for all pages automatically
# - hide expand only when click on the sidebar toggle icon.
Expand Down Expand Up @@ -365,7 +365,7 @@ mobile_layout_economy: false
# Android Chrome header panel color ($brand-bg / $headband-bg => $black-deep).
android_chrome_color: "#222"

# Custom Logo.
# Custom Logo
# Do not support Scheme Mist currently.
# Options:
# enabled: If true, will enable custom logo
Expand Down Expand Up @@ -459,11 +459,13 @@ math:
mathjax:
# Use 2.7.1 as default, jsdelivr as default CDN, works everywhere even in China
cdn: //cdn.jsdelivr.net/npm/mathjax@2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# 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
Copy link
Member

Choose a reason for hiding this comment

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

Check this link – it's worked for now, i think no need to remove it.

Copy link
Contributor Author

@stevenjoezhang stevenjoezhang Dec 31, 2018

Choose a reason for hiding this comment

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

http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML just make a redirect to https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js, and you can see console.warn('WARNING: cdn.mathjax.org has been retired. Check https://www.mathjax.org/cdn-shutting-down/ for migration tips.') in the script.
I suggest removing it.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, remove it. Under your responsibility. =)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

=)

# For direct link to MathJax.js with CloudFlare CDN (cdnjs.cloudflare.com).
# 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

# See: https://mhchem.github.io/MathJax-mhchem/
#mhchem: //cdn.jsdelivr.net/npm/mathjax-mhchem@3
Copy link
Member

Choose a reason for hiding this comment

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

And maybe this link wrong too.

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 have tested it, mathjax will load //cdn.jsdelivr.net/npm/mathjax-mhchem@3.3.0/mhchem.js, no problem here

#mhchem: //cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.0
Copy link
Member

Choose a reason for hiding this comment

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

Also, this link not working. (403)

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 will request cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.0/mhchem.js automatically, instead of cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.0, it works fine


# hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) needed to full Katex support.
katex:
# Use 0.7.1 as default, jsdelivr as default CDN, works everywhere even in China
Expand Down Expand Up @@ -547,7 +549,7 @@ valine:
#livere_uid: your uid

# Gitment
# Introduction: https://imsun.net/posts/gitment-introduction
# Introduction: https://github.com/imsun/gitment
gitment:
enable: false
mint: true # RECOMMEND, A mint on Gitment, to support count, language and proxy_gateway
Expand Down Expand Up @@ -575,7 +577,7 @@ gitalk:
distraction_free_mode: true # Facebook-like distraction free mode

# Baidu Share
# Available value:
# Available values:
# button | slide
# Warning: Baidu Share does not support https.
#baidushare:
Expand All @@ -586,8 +588,7 @@ gitalk:

# NeedMoreShare2
# Dependencies: https://github.com/theme-next/theme-next-needmoreshare2
# See: https://github.com/revir/need-more-share2
# Also see: https://github.com/DzmVasileusky/needShareButton
# See: https://github.com/revir/need-more-share2, https://github.com/DzmVasileusky/needShareButton
# iconStyle: default | box
# boxForm: horizontal | vertical
# position: top / middle / bottom + Left / Center / Right
Expand Down Expand Up @@ -772,6 +773,7 @@ bookmark:
# Tags Settings
# ---------------------------------------------------------------

# See: https://theme-next.org/docs/tag-plugins/
# Note tag (bs-callout)
note:
# Note tag style values:
Expand Down
17 changes: 14 additions & 3 deletions layout/_third-party/math/mathjax.swig
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
<script type="text/x-mathjax-config">
{% if theme.math.mathjax.mhchem %}
MathJax.Ajax.config.path['mhchem'] = '{{ theme.math.mathjax.mhchem }}';
{% endif %}

MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
TeX: {equationNumbers: { autoNumber: "AMS" }}
TeX: {
{% if theme.math.mathjax.mhchem %}
extensions: ['[mhchem]/mhchem.js'],
Copy link
Member

Choose a reason for hiding this comment

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

Oh, i see. Maybe try to add in CDN's settings something like //cdn.jsdelivr.net/npm/mathjax-mhchem@3/mhchem.min.js and stay here only extensions: ['[mhchem]']?

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, //cdn.jsdelivr.net/npm/mathjax-mhchem@3 is confusing... I'll fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that mathjax can't parse extensions: ['[mhchem]'] ... The syntax follows https://mhchem.github.io/MathJax-mhchem/ is the correctly way
Maybe no need to change

Copy link
Member

Choose a reason for hiding this comment

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

Mb because MathJax.Ajax.config.path exists above.
Ok, don't stay it as is. Mb later we can optimize it. 🥇

{% endif %}
equationNumbers: {
autoNumber: "AMS"
}
}
});
</script>

<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for (i=0; i < all.length; i += 1) {
for (i = 0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
Expand Down