mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-09-23 18:29:39 +00:00
Add support to MathJax for RGB colors
PS2: Make the number matcher limited to 3 digits. Fix at base 10. Originally, but had broken merge: Iff04d5d650ae87d957d57420f71975ccdf4a5370 Change-Id: I6885ea90e920734e324b6d1d1f70af69cdeab033
This commit is contained in:
parent
318f6777f5
commit
99a23e4af0
16
modules/MathJax/extensions/TeX/texvc.js
vendored
16
modules/MathJax/extensions/TeX/texvc.js
vendored
|
@ -7,6 +7,22 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
|||
|
||||
var MML = MathJax.ElementJax.mml;
|
||||
|
||||
/*
|
||||
* Get an RGB color (a triplet of values between 0 and 255)
|
||||
*/
|
||||
MathJax.Extension["TeX/color"].get_RGB = function (rgb) {
|
||||
rgb = rgb.split(/,/); var RGB = "#";
|
||||
if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 decimal numbers")}
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (!rgb[i].match(/^(\d{1,3})$/)) {this.TEX.Error("Invalid decimal number")}
|
||||
var n = parseInt(rgb[i], 10);
|
||||
if (n < 0 || n > 255) {this.TEX.Error("RGB values must be between 0 and 255")}
|
||||
n = n.toString(16); if (n.length < 2) {n = "0"+n}
|
||||
RGB += n;
|
||||
}
|
||||
return RGB;
|
||||
}
|
||||
|
||||
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions,{
|
||||
|
||||
mathchar0mi: {
|
||||
|
|
Loading…
Reference in a new issue