mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-03 23:32:58 +00:00
Add new var math functions
This commit is contained in:
@@ -46,6 +46,27 @@ const mathParser = new MathParser({
|
|||||||
array : false, fndef : false
|
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
|
//Processes the markdown within an HTML block if it's just a class-wrapper
|
||||||
renderer.html = function (html) {
|
renderer.html = function (html) {
|
||||||
|
|||||||
Reference in New Issue
Block a user