0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Add new var math functions

This commit is contained in:
G.Ambatte
2024-07-21 00:18:06 +12:00
parent 4fe38e3929
commit aebfcc7885

View File

@@ -46,6 +46,27 @@ const mathParser = new MathParser({
array : false, fndef : false
}
});
// Add absolute function
mathParser.functions.abs = function (a) {
return Math.abs(a);
};
// Add sign function
mathParser.functions.sign = function (a) {
if(a == 0) return '';
if(a > 0) {
return '\\+';
} else {
return '\\-';
}
};
// Add signed function
mathParser.functions.signed = function (a) {
if(a >= 0) {
return `\\+${a}`;
} else {
return `\\${a}`;
}
};
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (html) {