mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-05 17:40:33 +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>
34 lines
927 B
Ruby
34 lines
927 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "fileutils"
|
|
|
|
module DiscourseMath
|
|
module BundlePaths
|
|
PLUGIN_NAME = "discourse-math"
|
|
PUBLIC_DIR = File.expand_path("../../public", __dir__)
|
|
|
|
def self.bundle_version
|
|
DiscourseMathBundle::VERSION
|
|
end
|
|
|
|
def self.public_version_dir
|
|
File.join(PUBLIC_DIR, bundle_version)
|
|
end
|
|
|
|
def self.public_url_base
|
|
"/plugins/#{PLUGIN_NAME}/#{bundle_version}"
|
|
end
|
|
|
|
def self.ensure_public_symlinks
|
|
FileUtils.mkdir_p(public_version_dir)
|
|
ensure_symlink(File.join(public_version_dir, "mathjax"), DiscourseMathBundle.mathjax_path)
|
|
ensure_symlink(File.join(public_version_dir, "katex"), DiscourseMathBundle.katex_path)
|
|
end
|
|
|
|
def self.ensure_symlink(link_path, target_path)
|
|
return if File.symlink?(link_path) && File.readlink(link_path) == target_path
|
|
|
|
Discourse::Utils.atomic_ln_s(target_path, link_path)
|
|
end
|
|
end
|
|
end
|