yous / whiteglass

Minimal, responsive Jekyll theme for hackers
https://yous.github.io/whiteglass/
MIT License
732 stars 201 forks source link

Add MathJax block and inline equation #51

Closed whatasame closed 10 months ago

whatasame commented 11 months ago

Why MathJax?

GitHub supports MathJax in Markdown, ensuring compatibility with Jekyll as well.

Changes

Testing

Successfully tested in the local environment. Refer to the screenshot below:

Snipaste_2023-12-23_20-29-51

Thank you for your theme!

yous commented 11 months ago

Hi, thank you for the pull request!

I think you can use MathJax by editing _includes/head_custom.html of your blog with the following content:

<script>
MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']]
  }
};
</script>
<script id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>

or for SVG version:

<script>
MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']]
  },
  svg: {
    fontCache: 'global'
  }
};
</script>
<script id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

For more details about customization, see https://github.com/yous/whiteglass/blob/master/README.md#customization.

whatasame commented 10 months ago

Thanks for your feedback on the pull request!

I'm aware of the method you suggested, and I appreciate your recommendation. However, I believe that enabling MathJax support directly in the whiteglass would provide a more consistent experience for theme users. By doing so, we can ensure a unified rendering of mathematical expressions for all users as much as the content on GitHub.

If you don't have any plans to add this feature, feel free to close the pull request. 🤗 Thanks again for your understanding.

yous commented 10 months ago

When we add MathJax script to _includes/head.html, it can't be configured by users, users can't select between MathJax@2 and MathJax@3, and they can't stop requesting the script even when they don't have any TeX expression in their site.

Maybe we can add a variable to _config.yml, but then we should also handle options like inlineMath, etc., so I prefer to let users configure MathJax by themselves.

Thank you for the pull request again!