mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 08:13:47 +08:00
This upgrades to Mathjax 4.1 and latest katex Implement rich text composer support for math Adds support for /( )/ and /[ /] which was missing and very common now Removes math javascript from our repo --------- Co-authored-by: Mark McClure <mcmcclur@unca.edu>
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# name: discourse-math
|
|
# about: Uses MathJax 4.1 or KaTeX to render math expressions.
|
|
# meta_topic_id: 65770
|
|
# version: 0.9
|
|
# authors: Sam Saffron (sam)
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-math
|
|
|
|
require "discourse_math_bundle"
|
|
require_relative "lib/discourse_math/bundle_paths"
|
|
|
|
register_asset "stylesheets/common/discourse-math.scss"
|
|
register_asset "stylesheets/ext/discourse-chat.scss"
|
|
register_svg_icon "square-root-variable"
|
|
|
|
enabled_site_setting :discourse_math_enabled
|
|
|
|
begin
|
|
DiscourseMath::BundlePaths.ensure_public_symlinks
|
|
rescue => e
|
|
# the alternative of failing to boot is worse
|
|
Discourse.warn_exception(e, message: "Failed to create symlinks for discourse-math assets")
|
|
end
|
|
|
|
after_initialize do
|
|
add_to_serializer(:site, :discourse_math_bundle_url) do
|
|
DiscourseMath::BundlePaths.public_url_base
|
|
end
|
|
|
|
if respond_to?(:chat) && SiteSetting.chat_enabled
|
|
chat&.enable_markdown_feature("discourse-math")
|
|
chat&.enable_markdown_feature("math")
|
|
chat&.enable_markdown_feature("asciimath") if SiteSetting.discourse_math_enable_asciimath
|
|
end
|
|
end
|