Skip to content

Conversation

@joshlk
Copy link

@joshlk joshlk commented Nov 24, 2025

Type of change

  • New feature (non-breaking change which adds functionality)

Description

This PR adds support for KaTeX as an alternative math rendering engine to the existing MathJax implementation. Users can now choose between client-side rendering (MathJax) or server-side rendering (KaTeX) for mathematical expressions.

This can improve performance as KaTeX renders math expressions at build time, eliminating the need for client-side JavaScript processing and resulting in faster page loads. The changes maintain full backward compatibility, as it defaults back to MathJax if the user does no config changes.

KaTex does have some LaTeX missing features, such as \label is not supported.

Changes

Configuration

  • Added math.engine setting to _config.yml with options: mathjax (default) or katex
  • Added jektex configuration block for KaTeX rendering options (cache directory, ignore patterns, macros)
  • Added jektex ~> 0.1.1 gem dependency to jekyll-theme-chirpy.gemspec

Template Logic

  • Modified js-selector.html to conditionally load MathJax based on engine selection
  • Modified head.html to conditionally load KaTeX CSS when using KaTeX engine
  • Updated asset paths in basic.yml and cors.yml to include KaTeX CSS

Styling

  • Added overflow handling for .katex-display in _base.scss to prevent layout issues with wide equations

Documentation

  • Updated 2019-08-08-write-a-new-post.md with comprehensive documentation on:
    • How to choose between MathJax and KaTeX
    • Comparison of features and trade-offs
    • Configuration examples
    • Known limitations (KaTeX doesn't support \label and \eqref)
  • Simplified math examples in 2019-08-08-text-and-typography.md (removed equation references for KaTeX compatibility)
  • Added feature entry to CHANGELOG.md

Usage

Using MathJax (default, no changes required):

math:
  engine: # empty or 'mathjax'

Using KaTeX:

math:
  engine: katex

jektex:
  ignore: ["*.xml"]  # Process markdown files, ignore feed.xml

Then add jektex to your Gemfile and run bundle install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant