Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-math

Package Overview
Dependencies
Maintainers
7
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-math

Add KaTeX and MathJax support to Hexo

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

hexo-math

Tester npm version npm license npm download

Embed KaTeX and MathJax in Hexo post/page via tag plugins. Equations are rendered in Hexo (server-side), so browser-side javascript library is not needed and should be removed. CSS stylesheets are included by default but can be easily replaced.

Installation

$ npm i hexo-math --save
  • Requires Hexo 5+

Usage

KaTeX

{% katex '{options}' %}
content
{% endkatex %}

Examples

{% katex %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

Override front-matter and global options for a particular content. Options must be specified in JSON format.

{% katex '{ "output": "mathml", "felqn": true, "minRuleThickness": 0.05, "throwOnError": true }' %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

MathJax

{% mathjax '{options}' %}
content
{% endmathjax %}

Examples

{% mathjax %}
\frac{1}{x^2-1}
{% endmathjax %}

Override front-matter and global options for a particular content. Options must be specified in JSON format.

{% mathjax '{ "conversion": { "em": 14 }, "tex": { "tags": "ams" }, "svg": { "exFactor": 0.03 } }' %}
\frac{1}{x^2-1}
{% endmathjax %}

Per-article configuration

Override the global options via the front-matter of an article (post/page) basis.

---
title: On the Electrodynamics of Moving Bodies
categories: Physics
date: 1905-06-30 12:00:00
katex: false
mathjax: false
---

Options

Disable math renderer in an article:

---
katex: false
mathjax: false
---

Override global options:

---
katex:
  output: 'mathml'
  felqn: true
  minRuleThickness: 0.05
  throwOnError: true
mathjax:
  conversion:
    em: 14
  tex:
    tags: 'ams'
  svg:
    exFactor: 0.03
---

Global Options

# _config.yml
math:
  katex:
    css: 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css'
    options:
      throwOnError: false
  mathjax:
    css: 'https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css'
    options:
      conversion:
        display: false
      tex:
      svg:
  • css: Location of stylesheet.
    • Specify a relative path if you're self-hosting the stylesheet.
      • Example: css: '/css/style.css' refers to source/css/style.css or themes/<theme-name>/source/css/style.css.
    • It can be disabled (css: false) if the installed theme has already included one.

KaTeX

  katex:
    options:
      throwOnError: false

MathJax

  mathjax:
    options:
      conversion:
        display: false
      tex:
      svg:

Configuration priority

Unique options are combined, if there is any duplicate options, argument overrides front-matter, front-matter overrides global options.

Example:

{% katex '{ "output": "html", "felqn": true }' %}
content
{% endkatex %}
# front-matter
---
katex:
  output: 'mathml'
  minRuleThickness: 0.05
  throwOnError: true
---
# _config.yml
math:
  katex:
    options:
      minRuleThickness: 0.03
      maxExpand: 900

Following options will be parsed as argument for that specific content:

{
  output: 'html',
  felqn: true,
  minRuleThickness: 0.05,
  throwOnError: true,
  maxExpand: 900
}

Similar project

  • hexo-filter-mathjax: A MathJax plugin developed by @stevenjoezhang, who is also a Hexo developer. It enables you to write LaTeX in-line within your post without using a tag {% %}.
    • hexo-math uses tag plugin approach due to minor incompatibility between LaTeX and marked, the default markdown renderer of Hexo (via hexo-renderer-marked).

Keywords

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc