mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-09 04:58:40 +00:00
Support \colorbox and \fcolorbox (#886)
* Support \colorbox and \\fcolorbox These are functions from the `color` package. They accept text, not math. They also have padding similar to `\fbox`. Because of the padding, the code in `buildHTML` is intermixed with the `\fbox` code. I have not (yet) created a new file in the functions folder. This way, the reviewer gets a cleaner diff. * Fix lint error * colorbox screenshots * Pick up review comments
This commit is contained in:
@@ -88,6 +88,42 @@ defineFunction(["\\color"], {
|
||||
argTypes: ["color"],
|
||||
}, null);
|
||||
|
||||
// colorbox
|
||||
defineFunction(["\\colorbox"], {
|
||||
numArgs: 2,
|
||||
allowedInText: true,
|
||||
greediness: 3,
|
||||
argTypes: ["color", "text"],
|
||||
}, function(context, args) {
|
||||
const color = args[0];
|
||||
const body = args[1];
|
||||
return {
|
||||
type: "enclose",
|
||||
label: context.funcName,
|
||||
backgroundColor: color,
|
||||
body: body,
|
||||
};
|
||||
});
|
||||
|
||||
// fcolorbox
|
||||
defineFunction(["\\fcolorbox"], {
|
||||
numArgs: 3,
|
||||
allowedInText: true,
|
||||
greediness: 3,
|
||||
argTypes: ["color", "color", "text"],
|
||||
}, function(context, args) {
|
||||
const borderColor = args[0];
|
||||
const backgroundColor = args[1];
|
||||
const body = args[2];
|
||||
return {
|
||||
type: "enclose",
|
||||
label: context.funcName,
|
||||
backgroundColor: backgroundColor,
|
||||
borderColor: borderColor,
|
||||
body: body,
|
||||
};
|
||||
});
|
||||
|
||||
// An overline
|
||||
defineFunction(["\\overline"], {
|
||||
numArgs: 1,
|
||||
|
Reference in New Issue
Block a user