From 5bb5cdec050af4c3c4e5e7dddfdc099e6e90c77d Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Fri, 9 Aug 2024 13:10:30 +1200 Subject: [PATCH 1/6] Change replaceAll to use RegEx from string --- shared/naturalcrit/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 518b48705..5ffb79f5b 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -462,7 +462,7 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) { mathVars?.forEach((variable)=>{ const foundVar = lookupVar(variable, globalPageNumber, hoist); if(foundVar && foundVar.resolved && foundVar.content && !isNaN(foundVar.content)) // Only subsitute math values if fully resolved, not empty strings, and numbers - replacedLabel = replacedLabel.replaceAll(variable, foundVar.content); + replacedLabel = replacedLabel.replaceAll(new RegExp(`/(? Date: Fri, 9 Aug 2024 15:33:28 +1200 Subject: [PATCH 2/6] Fix typo in regex --- shared/naturalcrit/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 5ffb79f5b..f7f1763e5 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -462,7 +462,7 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) { mathVars?.forEach((variable)=>{ const foundVar = lookupVar(variable, globalPageNumber, hoist); if(foundVar && foundVar.resolved && foundVar.content && !isNaN(foundVar.content)) // Only subsitute math values if fully resolved, not empty strings, and numbers - replacedLabel = replacedLabel.replaceAll(new RegExp(`/(? Date: Fri, 9 Aug 2024 17:42:15 +1200 Subject: [PATCH 3/6] Add variable name checks --- tests/markdown/variables.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/markdown/variables.test.js b/tests/markdown/variables.test.js index e6018e19f..3a03d64f6 100644 --- a/tests/markdown/variables.test.js +++ b/tests/markdown/variables.test.js @@ -370,4 +370,18 @@ describe('Cross-page variables', ()=>{ const rendered = renderAllPages([source0, source1]).join('\n\\page\n').trimReturns(); expect(rendered, `Input:\n${[source0, source1].join('\n\\page\n')}`, { showPrefix: false }).toBe('

two

one

\\page

two

'); }); +}); + +describe('Variable name as a subset of a function or other variable name', ()=>{ + it('Variable name as a subset of a function', function() { + const source = `[a]: -1\n\n$[abs(a)]`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered).toBe('

1

'); + }); + + it('Variable name as a subset of another variable name', function() { + const source = `[ab]: 2\n\n[aba]: 8\n\n[ba]: 4\n\n$[ab + aba + ba]`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered).toBe('

14

'); + }); }); \ No newline at end of file From f58d52c4b6d91a938cc8be0c04efbd626bb38d31 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 10 Aug 2024 07:54:50 +1200 Subject: [PATCH 4/6] Add comma to var math split regex --- shared/naturalcrit/markdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 518b48705..49c2d8fa0 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -452,7 +452,7 @@ const replaceVar = function(input, hoist=false, allowUnresolved=false) { const label = match[2]; //v=====--------------------< HANDLE MATH >-------------------=====v// - const mathRegex = /[a-z]+\(|[+\-*/^()]/g; + const mathRegex = /[a-z]+\(|[+\-*/^(),]/g; const matches = label.split(mathRegex); const mathVars = matches.filter((match)=>isNaN(match))?.map((s)=>s.trim()); // Capture any variable names From 5c4187cd06ed7e8946bf76dadc155f9c5080c25b Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 10 Aug 2024 08:24:16 +1200 Subject: [PATCH 5/6] Add variable names as function parameter tests --- tests/markdown/variables.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/markdown/variables.test.js b/tests/markdown/variables.test.js index e6018e19f..f53f5558d 100644 --- a/tests/markdown/variables.test.js +++ b/tests/markdown/variables.test.js @@ -370,4 +370,22 @@ describe('Cross-page variables', ()=>{ const rendered = renderAllPages([source0, source1]).join('\n\\page\n').trimReturns(); expect(rendered, `Input:\n${[source0, source1].join('\n\\page\n')}`, { showPrefix: false }).toBe('

two

one

\\page

two

'); }); +}); + +describe('Variable names as function parameters', ()=>{ + it('Single parameter as variable', function() { + const source = '[var]:4.1\n\n$[floor(var)]'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

4

`); + }); + it('Two parameters, one variable', function() { + const source = '[var]:4\n\n$[min(1,var)]'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

1

`); + }); + it('Two parameters, both variables', function() { + const source = '[var1]:4\n\n[var2]:8\n\n$[min(var1,var2)]'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

4

`); + }); }); \ No newline at end of file From aa945c41777fac3522fb012a0aa139e751be00aa Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 13 Aug 2024 17:08:59 -0400 Subject: [PATCH 6/6] Up to v3.14.1 --- changelog.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 0cdb89c29..033eee86d 100644 --- a/changelog.md +++ b/changelog.md @@ -84,6 +84,65 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Tuesday 8/13/2024 - v3.14.1 +{{taskList + +##### abquintic + +* [x] Allow Table of Contents to flow across columns + +Fixes issues [#2563](https://github.com/naturalcrit/homebrewery/issues/2563) + +* [x] Fix unusual margin spacing for adjacent `.descriptive` and `.wide` blocks + +Fixes issues [#2688](https://github.com/naturalcrit/homebrewery/issues/2688) + +* [x] Add code folding to :fas_paintbrush: {{openSans **STYLE**}} tab + +##### G-Ambatte + +* [x] Fix edge case where Table of Contents generator changed capitalization of headings + +Fixes issues [#3572](https://github.com/naturalcrit/homebrewery/issues/3572) + +* [x] Fix **Ink Friendly** snippet causing unselectable PDF text + +Fixes issues [#3563](https://github.com/naturalcrit/homebrewery/issues/3563) + +* [x] Prevent brews selecting themselves as a theme + +Fixes issues [#3614](https://github.com/naturalcrit/homebrewery/issues/3614) + +* [x] Fix info pages (`/faq`, `/migrate`, etc.) showing blank authorship info + +Fixes issues [#3568](https://github.com/naturalcrit/homebrewery/issues/3568) + +* [x] Add `abs()`, `sign()` and `signed()` functions to variable syntax math handler + +Fixes issues [#3537](https://github.com/naturalcrit/homebrewery/issues/3537) + +* [x] Fix variable math handler not processing commas (i.e., in `$[max(varA,varB)]` + +Fixes issues [#3613](https://github.com/naturalcrit/homebrewery/issues/3613) + +* [x] Fix variable math handler scrambling variables with names that are subsets of other variables + +Fixes issues [#3622](https://github.com/naturalcrit/homebrewery/issues/3622) + + +##### calculuschild + +* [x] Fix `/migrate` page using an editor context instead of share context + + +##### 5e-Cleric + +* [x] Fix Monster Stat Blocks losing color in Safari + +}} + +\page + ### Monday 7/29/2024 - v3.14.0 {{taskList diff --git a/package-lock.json b/package-lock.json index e025814ae..63df75509 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebrewery", - "version": "3.14.0", + "version": "3.14.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebrewery", - "version": "3.14.0", + "version": "3.14.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 2dbff24ed..b417e7e3b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "3.14.0", + "version": "3.14.1", "engines": { "npm": "^10.2.x", "node": "^20.8.x"