Skip to content

Commit 9508c3f

Browse files
committed
Merge 'issue287' into develop
2 parents e33cc5a + 049739b commit 9508c3f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

extensions/TeX/color.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unpacked/extensions/TeX/color.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* MathJax/extensions/TeX/color.js
44
*
55
* Implements LaTeX-compatible \color macro rather than MathJax's original
6-
* (non-standard) version. It includes the rgb, gray, and named color
6+
* (non-standard) version. It includes the rgb, RGB, gray, and named color
77
* models, and the \textcolor, \definecolor, \colorbox, and \fcolorbox
88
* macros.
99
*
@@ -117,21 +117,37 @@ MathJax.Extension["TeX/color"] = {
117117
},
118118

119119
/*
120-
* Get an RGB color
120+
* Get an rgb color
121121
*/
122122
get_rgb: function (rgb) {
123123
rgb = rgb.split(/,/); var RGB = "#";
124-
if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 decimal numbers")}
124+
if (rgb.length !== 3) {this.TEX.Error("rgb colors require 3 decimal numbers")}
125125
for (var i = 0; i < 3; i++) {
126126
if (!rgb[i].match(/^(\d+(\.\d*)?|\.\d+)$/)) {this.TEX.Error("Invalid decimal number")}
127127
var n = parseFloat(rgb[i]);
128-
if (n < 0 || n > 1) {this.TEX.Error("RGB values must be between 0 and 1")}
128+
if (n < 0 || n > 1) {this.TEX.Error("rgb values must be between 0 and 1")}
129129
n = Math.floor(n*255).toString(16); if (n.length < 2) {n = "0"+n}
130130
RGB += n;
131131
}
132132
return RGB;
133133
},
134134

135+
/*
136+
* Get an RGB color
137+
*/
138+
get_RGB: function (rgb) {
139+
rgb = rgb.split(/,/); var RGB = "#";
140+
if (rgb.length !== 3) {this.TEX.Error("RGB colors require 3 numbers")}
141+
for (var i = 0; i < 3; i++) {
142+
if (!rgb[i].match(/^\d+$/)) {this.TEX.Error("Invalid number")}
143+
var n = parseInt(rgb[i]);
144+
if (n > 255) {this.TEX.Error("RGB values must be between 0 and 255")}
145+
n = n.toString(16); if (n.length < 2) {n = "0"+n}
146+
RGB += n;
147+
}
148+
return RGB;
149+
},
150+
135151
/*
136152
* Get a gray-scale value
137153
*/

0 commit comments

Comments
 (0)