mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 22:18:41 +00:00
Fix color support for stretchy, strikethrough, and fbox (#792)
Summary: Stuff like `\red{\overbrace{AB}}` works now in addition to `\color{red}{\overbrace{AB}}`. Strikethrough now respects color. The Firefox in the screenshotter doesn't seem to support `background-image` + `mask`, but I manually tested that the latest Firefox does. Test plan: Ran `make`, then tested in latest Chrome and Firefox to ensure color support was working, then ran `make screenshots`.
This commit is contained in:
committed by
Kevin Barabash
parent
e192be2177
commit
d01c73c312
@@ -143,7 +143,7 @@ const svgSpan = function(group, options) {
|
|||||||
classArray.push("mask"); // Over-ride image.
|
classArray.push("mask"); // Over-ride image.
|
||||||
classArray.push(fileName + "-mask"); // Set mask-image.
|
classArray.push(fileName + "-mask"); // Set mask-image.
|
||||||
node = buildCommon.makeSpan(classArray, [], options);
|
node = buildCommon.makeSpan(classArray, [], options);
|
||||||
node.style.backgroundColor = options.color;
|
node.style.backgroundColor = options.getColor();
|
||||||
} else {
|
} else {
|
||||||
classArray.push(fileName); // Set image and span height.
|
classArray.push(fileName); // Set image and span height.
|
||||||
node = buildCommon.makeSpan(classArray, [], options);
|
node = buildCommon.makeSpan(classArray, [], options);
|
||||||
@@ -161,10 +161,10 @@ const encloseSpan = function(inner, isCharBox, label, pad, options) {
|
|||||||
|
|
||||||
if (options.color) {
|
if (options.color) {
|
||||||
if (label === "fbox") {
|
if (label === "fbox") {
|
||||||
img.style.borderColor = options.color;
|
img.style.borderColor = options.getColor();
|
||||||
} else {
|
} else {
|
||||||
img.classes[2] = label + "-mask";
|
img.classes[2] = label + "-mask";
|
||||||
img.style.backgroundColor = options.color;
|
img.style.backgroundColor = options.getColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -853,7 +853,10 @@
|
|||||||
// This section won't be applied by some older browsers, so they will instead
|
// This section won't be applied by some older browsers, so they will instead
|
||||||
// render the black background-image defined above.
|
// render the black background-image defined above.
|
||||||
|
|
||||||
.mask {
|
.mask,
|
||||||
|
.bcancel-mask,
|
||||||
|
.cancel-mask,
|
||||||
|
.xcancel-mask {
|
||||||
background-image: none;
|
background-image: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test/screenshotter/images/StretchyAccentColor-chrome.png
Normal file
BIN
test/screenshotter/images/StretchyAccentColor-chrome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/StretchyAccentColor-firefox.png
Normal file
BIN
test/screenshotter/images/StretchyAccentColor-firefox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
test/screenshotter/images/StrikeThroughColor-chrome.png
Normal file
BIN
test/screenshotter/images/StrikeThroughColor-chrome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
test/screenshotter/images/StrikeThroughColor-firefox.png
Normal file
BIN
test/screenshotter/images/StrikeThroughColor-firefox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@@ -52,8 +52,8 @@ Cases: |
|
|||||||
Colors:
|
Colors:
|
||||||
tex: \blue{a}\textcolor{#0f0}{b}\textcolor{red}{c}
|
tex: \blue{a}\textcolor{#0f0}{b}\textcolor{red}{c}
|
||||||
nolatex: different syntax and different scope
|
nolatex: different syntax and different scope
|
||||||
ColorSpacing: \textcolor{red}{\displaystyle \int x} + 1
|
|
||||||
ColorImplicit: bl{ack\color{red}red\textcolor{green}{green}red\color{blue}blue}black
|
ColorImplicit: bl{ack\color{red}red\textcolor{green}{green}red\color{blue}blue}black
|
||||||
|
ColorSpacing: \textcolor{red}{\displaystyle \int x} + 1
|
||||||
DashesAndQuotes: \text{``a'' b---c -- d----`e'-{-}-f}--``x''
|
DashesAndQuotes: \text{``a'' b---c -- d----`e'-{-}-f}--``x''
|
||||||
DeepFontSizing:
|
DeepFontSizing:
|
||||||
tex: |
|
tex: |
|
||||||
@@ -203,6 +203,8 @@ StretchyAccent: |
|
|||||||
\overrightarrow{F} + \overrightarrow{AB} + \overrightarrow{F}^2 + \overrightarrow{F}_2 + \overrightarrow{F}_1^2 \\
|
\overrightarrow{F} + \overrightarrow{AB} + \overrightarrow{F}^2 + \overrightarrow{F}_2 + \overrightarrow{F}_1^2 \\
|
||||||
\overrightarrow{AB}^2+\frac{\overrightarrow{AB}}{\overrightarrow{AB}} + \sqrt{\overrightarrow{AB}} + \left\lvert\overrightarrow{AB}\right\rvert
|
\overrightarrow{AB}^2+\frac{\overrightarrow{AB}}{\overrightarrow{AB}} + \sqrt{\overrightarrow{AB}} + \left\lvert\overrightarrow{AB}\right\rvert
|
||||||
\end{array}
|
\end{array}
|
||||||
|
StretchyAccentColor: |
|
||||||
|
\red{\overrightarrow{AB}} \quad \color{blue}{\overleftarrow{AB}} \quad \color{blue}{\green{\Overrightarrow{AB}}}
|
||||||
StrikeThrough: |
|
StrikeThrough: |
|
||||||
\begin{array}{l}
|
\begin{array}{l}
|
||||||
\cancel x \quad \cancel{2B} + \bcancel 5 +\bcancel{5ay} \\
|
\cancel x \quad \cancel{2B} + \bcancel 5 +\bcancel{5ay} \\
|
||||||
@@ -210,6 +212,11 @@ StrikeThrough: |
|
|||||||
\frac{x+\cancel B}{x+\cancel x} + \frac{x+\cancel y}{x} + \cancel{B}_1^2 + \cancel{B^2} \\
|
\frac{x+\cancel B}{x+\cancel x} + \frac{x+\cancel y}{x} + \cancel{B}_1^2 + \cancel{B^2} \\
|
||||||
\left\lvert\cancel{ac}\right\rvert
|
\left\lvert\cancel{ac}\right\rvert
|
||||||
\end{array}
|
\end{array}
|
||||||
|
StrikeThroughColor: |
|
||||||
|
\begin{array}{l}
|
||||||
|
\red{\cancel x \quad \cancel{2B} + \bcancel 5 +\bcancel{5ay}} \\
|
||||||
|
\color{green}{\sout{5ab} + \sout{5ABC} + \xcancel{\oint_S{\vec E\cdot\hat n\,\mathrm d a}}}
|
||||||
|
\end{array}
|
||||||
StyleSpacing: \scriptstyle ab\;cd
|
StyleSpacing: \scriptstyle ab\;cd
|
||||||
StyleSwitching: a\cdot b\scriptstyle a\cdot ba\textstyle\cdot ba\scriptstyle\cdot b
|
StyleSwitching: a\cdot b\scriptstyle a\cdot ba\textstyle\cdot ba\scriptstyle\cdot b
|
||||||
SupSubCharacterBox: a_2f_2{f}_2{aa}_2{af}_2\mathbf{y}_Ay_A
|
SupSubCharacterBox: a_2f_2{f}_2{aa}_2{af}_2\mathbf{y}_Ay_A
|
||||||
|
Reference in New Issue
Block a user