From aebfcc7885abd3bac4b2148c8f057f644fc7dfc0 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sun, 21 Jul 2024 00:18:06 +1200 Subject: [PATCH 1/6] Add new var math functions --- shared/naturalcrit/markdown.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 39939f306..3dfc6c348 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -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) { From 6f99fe7455dc4db3f72307a615f6f7a0bc33908d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 2 Aug 2024 07:02:57 +1200 Subject: [PATCH 2/6] Update shared/naturalcrit/markdown.js Co-authored-by: Trevor Buckner --- shared/naturalcrit/markdown.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 3dfc6c348..65f9d8549 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -53,11 +53,8 @@ mathParser.functions.abs = function (a) { // Add sign function mathParser.functions.sign = function (a) { if(a == 0) return ''; - if(a > 0) { - return '\\+'; - } else { - return '\\-'; - } + if(a > 0) return '\\+'; + return '\\-'; }; // Add signed function mathParser.functions.signed = function (a) { From e1fe640e923ae27c820c72b970dd25367d975971 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 2 Aug 2024 07:03:27 +1200 Subject: [PATCH 3/6] Update shared/naturalcrit/markdown.js Co-authored-by: Trevor Buckner --- shared/naturalcrit/markdown.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 65f9d8549..157c608e1 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -58,11 +58,8 @@ mathParser.functions.sign = function (a) { }; // Add signed function mathParser.functions.signed = function (a) { - if(a >= 0) { - return `\\+${a}`; - } else { - return `\\${a}`; - } + if(a >= 0) return `\\+${a}`; + return `\\${a}`; }; //Processes the markdown within an HTML block if it's just a class-wrapper From fcd52793813c7435271d7fc2a46ec7a74714b611 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Aug 2024 10:32:18 +1200 Subject: [PATCH 4/6] Enable built-in `abs()` --- shared/naturalcrit/markdown.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 157c608e1..1cd62f0d1 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -28,17 +28,18 @@ const mathParser = new MathParser({ round : true, floor : true, ceil : true, + abs : true, sin : false, cos : false, tan : false, asin : false, acos : false, atan : false, sinh : false, cosh : false, tanh : false, asinh : false, acosh : false, atanh : false, sqrt : false, cbrt : false, log : false, log2 : false, ln : false, lg : false, log10 : false, expm1 : false, - log1p : false, abs : false, trunc : false, join : false, sum : false, + log1p : false, trunc : false, join : false, sum : false, indexOf : false, '-' : false, '+' : false, exp : false, not : false, length : false, '!' : false, sign : false, random : false, fac : false, min : false, max : false, hypot : false, pyt : false, pow : false, atan2 : false, 'if' : false, gamma : false, roundTo : false, map : false, fold : false, - filter : false, indexOf : false, + filter : false, remainder : false, factorial : false, comparison : false, concatenate : false, @@ -46,10 +47,6 @@ 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 ''; From 1b71bbaefbfce05f639ed8a695fdd49a734ef682 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Aug 2024 10:32:39 +1200 Subject: [PATCH 5/6] Remove escaping from new functions --- shared/naturalcrit/markdown.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 1cd62f0d1..518b48705 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -49,14 +49,13 @@ const mathParser = new MathParser({ }); // Add sign function mathParser.functions.sign = function (a) { - if(a == 0) return ''; - if(a > 0) return '\\+'; - return '\\-'; + if(a >= 0) return '+'; + return '-'; }; // Add signed function mathParser.functions.signed = function (a) { - if(a >= 0) return `\\+${a}`; - return `\\${a}`; + if(a >= 0) return `+${a}`; + return `${a}`; }; //Processes the markdown within an HTML block if it's just a class-wrapper From 1513a983f7fe4adb2a595d59668b7ed1efd56ad9 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 3 Aug 2024 16:32:49 +1200 Subject: [PATCH 6/6] Skip self when generating metadata dropdown list --- client/homebrew/editor/metadataEditor/metadataEditor.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index 4b48c2617..0f1f6ad54 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -28,6 +28,7 @@ const MetadataEditor = createClass({ return { metadata : { editId : null, + shareId : null, title : '', description : '', thumbnail : '', @@ -196,6 +197,7 @@ const MetadataEditor = createClass({ const listThemes = (renderer)=>{ return _.map(_.values(mergedThemes[renderer]), (theme)=>{ + if(theme.path == this.props.metadata.shareId) return; const preview = theme.thumbnail || `/themes/${theme.renderer}/${theme.path}/dropdownPreview.png`; const texture = theme.thumbnail || `/themes/${theme.renderer}/${theme.path}/dropdownTexture.png`; return
this.handleTheme(theme)} title={''}>