A Ruby gem that packages MathJax and KaTeX assets for the discourse-math plugin.
The discourse-math plugin needs MathJax and KaTeX JavaScript/CSS/font files to render mathematical notation. Rather than vendoring these large libraries directly in the plugin repository, this gem provides them as a dependency. This keeps the plugin lightweight and makes it easier to update math libraries independently.
Add to your Gemfile:
gem "discourse_math_bundle"require "discourse_math_bundle"
# Get paths to asset directories
DiscourseMathBundle.mathjax_path # => "/path/to/gem/vendor/assets/mathjax"
DiscourseMathBundle.katex_path # => "/path/to/gem/vendor/assets/katex"
# Get version info
DiscourseMathBundle.mathjax_version # => "4.1.0"
DiscourseMathBundle.katex_version # => "0.16.27"
# Get detailed path information
paths = DiscourseMathBundle.paths
paths[:mathjax][:core] # => path to core.js
paths[:katex][:js] # => path to katex.min.js
paths[:katex][:css] # => path to katex.min.css- Ruby >= 3.2
- pnpm >= 9
lib/: gem entry point and version constantsvendor/assets/: vendored MathJax and KaTeX bundlesRakefile: asset update, verification, and publish tasks
Refresh vendored assets from current npm versions:
bundle exec rake assets:updateUpgrade to latest npm package versions:
bundle exec rake assets:upgradeThis updates package.json, version constants in lib/discourse_math_bundle/version.rb, and copies fresh assets to vendor/assets/.
bundle exec rake assets:verifyThe gem is automatically published to RubyGems when changes are pushed to main. To release a new version:
- Bump the
VERSIONconstant inlib/discourse_math_bundle/version.rb - Commit and push to
main - CI detects the version change and publishes to RubyGems
Manual publishing is also available via bundle exec rake gem:publish.
Do not edit files in vendor/assets/ by hand; always regenerate via Rake tasks.
MIT