Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: checks test phpcs
.PHONY: checks test phpcs mathjax

MATHJAX_VERSION_LOCAL ?= 4.1.3
MATHJAX_VERSION_CDN ?= 4

checks: test phpcs ## Everything CI runs before merging (needs `composer install`, PHP >= 8.2)

Expand All @@ -7,3 +10,6 @@ test: ## Run the pure-PHP test suites

phpcs: ## parallel-lint + minus-x + phpcs against the MediaWiki coding standard
composer test

mathjax: ## Pin the local MathJax submodule + CDN major version, e.g. `make mathjax MATHJAX_VERSION_LOCAL=4.1.3 MATHJAX_VERSION_CDN=4`
hack/mathjax.sh $(MATHJAX_VERSION_LOCAL) $(MATHJAX_VERSION_CDN)
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SimpleMathJax",
"version": "0.11.0",
"version": "0.12.0",
"author": "jmnote",
"url": "https://www.mediawiki.org/wiki/Extension:SimpleMathJax",
"description": "render TeX between <code><nowiki><math></nowiki></code> and <code><nowiki></math></nowiki></code>",
Expand Down
31 changes: 31 additions & 0 deletions hack/mathjax.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Pins the resources/MathJax submodule to a tag and updates the CDN URL's
# major version in resources/ext.SimpleMathJax.js. The two are versioned
# separately on purpose: the local copy is pinned to an exact tag, while
# the CDN URL only pins a major version (jsdelivr resolves it to the
# latest matching release).
#
# Usage: hack/mathjax.sh <local-version> <cdn-major-version>
# e.g. hack/mathjax.sh 4.1.3 4
set -euo pipefail
cd "$(dirname "$0")/.."

MATHJAX_DIR="resources/MathJax"
JS_FILE="resources/ext.SimpleMathJax.js"
LOCAL_VERSION="${1:-}"
CDN_VERSION="${2:-}"

if [ -z "$LOCAL_VERSION" ] || [ -z "$CDN_VERSION" ]; then
echo "Usage: hack/mathjax.sh <local-version> <cdn-major-version> (e.g. hack/mathjax.sh 4.1.3 4)" >&2
exit 1
fi

git submodule update --init "$MATHJAX_DIR"
(cd "$MATHJAX_DIR" && git fetch --tags origin && git checkout "tags/$LOCAL_VERSION")
git add "$MATHJAX_DIR"

sed -i -E "s#(cdn\.jsdelivr\.net/npm/mathjax@)[^/]+#\1${CDN_VERSION}#" "$JS_FILE"
git add "$JS_FILE"

echo "==> Pinned $MATHJAX_DIR to $LOCAL_VERSION and the CDN URL to mathjax@$CDN_VERSION."
echo "==> Review with 'git status', then commit the bump."
2 changes: 1 addition & 1 deletion resources/MathJax
Submodule MathJax updated 212 files
4 changes: 2 additions & 2 deletions resources/ext.SimpleMathJax.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ window.MathJax = {
(function () {
var script = document.createElement('script');
script.src = mw.config.get('wgSmjUseCdn')
? 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
: mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/resources/MathJax/es5/tex-chtml.js';
? 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js'
: mw.config.get('wgExtensionAssetsPath') + '/SimpleMathJax/resources/MathJax/tex-chtml.js';
script.async = true;
document.head.appendChild(script);
})();
Expand Down
Loading