From 518c5d3ef6bc78274509703bf102f52844c8a5d7 Mon Sep 17 00:00:00 2001 From: Bram Chen Date: Fri, 19 Jan 2024 16:41:23 +0800 Subject: [PATCH 1/6] Update chinese language files (#7937) * Add description for "class" system field --- languages/zh-Hans/Fields.multids | 1 + languages/zh-Hant/Fields.multids | 1 + 2 files changed, 2 insertions(+) diff --git a/languages/zh-Hans/Fields.multids b/languages/zh-Hans/Fields.multids index fc545848d..b406a56ad 100644 --- a/languages/zh-Hans/Fields.multids +++ b/languages/zh-Hans/Fields.multids @@ -5,6 +5,7 @@ author: 一个插件作者的姓名 bag: 条目的来源集的名称 caption: 显示于页签或按钮上的标题文字 code-body: 若设置为 ''yes'',视图模板将以程式码形式显示条目 +class: 渲染条目时,套用到条目的 CSS 类别 - 请参阅[[依自订类别的自订样式|Custom styles by user-class]]。也适用于[[互动窗口|Modals]] color: 条目的 CSS 颜色值 component: 负责[[提醒条目|AlertMechanism]]的组件名称 core-version: 对于一个插件,表示与其兼容的 TiddlyWiki 版本 diff --git a/languages/zh-Hant/Fields.multids b/languages/zh-Hant/Fields.multids index ab2962b36..a41e8b65e 100644 --- a/languages/zh-Hant/Fields.multids +++ b/languages/zh-Hant/Fields.multids @@ -4,6 +4,7 @@ _canonical_uri: 外部圖片條目的完整的 URI author: 一個插件作者的姓名 bag: 條目的來源集的名稱 caption: 顯示於頁籤或按鈕上的標題文字 +class: 渲染條目時,套用到條目的 CSS 類別 - 請參閱[[依自訂類別的自訂樣式|Custom styles by user-class]]。也適用於[[互動視窗|Modals]] code-body: 若設定為 ''yes'',檢視範本將以程式碼形式顯示條目 color: 條目的 CSS 顏色值 component: 負責[[警示條目|AlertMechanism]]的元件名稱 From 100eaeff30cb052dcedde638559c4f6ccc06a3fc Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Mon, 22 Jan 2024 18:43:23 +0100 Subject: [PATCH 2/6] Moves some exsiting macro tests to their own folders (#7940) --- .../data/macros/{ => nested-macros}/NestedMacros-indented.tid | 0 .../data/macros/{ => nested-macros}/NestedMacros-indented2.tid | 0 .../tests/data/macros/{ => nested-macros}/NestedMacros.tid | 0 .../data/macros/{ => trailing-newlines}/TrailingNewlines.tid | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename editions/test/tiddlers/tests/data/macros/{ => nested-macros}/NestedMacros-indented.tid (100%) rename editions/test/tiddlers/tests/data/macros/{ => nested-macros}/NestedMacros-indented2.tid (100%) rename editions/test/tiddlers/tests/data/macros/{ => nested-macros}/NestedMacros.tid (100%) rename editions/test/tiddlers/tests/data/macros/{ => trailing-newlines}/TrailingNewlines.tid (100%) diff --git a/editions/test/tiddlers/tests/data/macros/NestedMacros-indented.tid b/editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros-indented.tid similarity index 100% rename from editions/test/tiddlers/tests/data/macros/NestedMacros-indented.tid rename to editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros-indented.tid diff --git a/editions/test/tiddlers/tests/data/macros/NestedMacros-indented2.tid b/editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros-indented2.tid similarity index 100% rename from editions/test/tiddlers/tests/data/macros/NestedMacros-indented2.tid rename to editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros-indented2.tid diff --git a/editions/test/tiddlers/tests/data/macros/NestedMacros.tid b/editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros.tid similarity index 100% rename from editions/test/tiddlers/tests/data/macros/NestedMacros.tid rename to editions/test/tiddlers/tests/data/macros/nested-macros/NestedMacros.tid diff --git a/editions/test/tiddlers/tests/data/macros/TrailingNewlines.tid b/editions/test/tiddlers/tests/data/macros/trailing-newlines/TrailingNewlines.tid similarity index 100% rename from editions/test/tiddlers/tests/data/macros/TrailingNewlines.tid rename to editions/test/tiddlers/tests/data/macros/trailing-newlines/TrailingNewlines.tid From fb85e91f82f597912b87fd449a5985bc668b9d9a Mon Sep 17 00:00:00 2001 From: btheado Date: Wed, 24 Jan 2024 06:32:58 -0500 Subject: [PATCH 3/6] Allows whitespace-only macro/procedure to be closed by \end (#7911) * Added some passing macro definition parsing tests * Added two failing tests to illustrate bug #3460 * Allow \end to end an whitespace only/empty macro definition. Fixes #3460 * Added some passing procedure definition tests * Added two failing procedure tests to illustrate bug #3460 * Allow \end to end a whitespace only/empty procedure/function/widget definition. Fixes #3640 * Fixed wording of comment --- .../parsers/wikiparser/rules/fnprocdef.js | 6 +++--- .../parsers/wikiparser/rules/macrodef.js | 6 +++--- .../tiddlers/tests/data/macros/EndInBody.tid | 16 ++++++++++++++++ .../tiddlers/tests/data/macros/IndentedEnd.tid | 16 ++++++++++++++++ .../tests/data/macros/MismatchedNamedEnd.tid | 16 ++++++++++++++++ .../data/macros/WhitespaceOnlyWithEnd.tid | 18 ++++++++++++++++++ .../data/macros/WhitespaceOnlyWithEnd2.tid | 15 +++++++++++++++ .../tests/data/procedures/EndInBody.tid | 16 ++++++++++++++++ .../tests/data/procedures/IndentedEnd.tid | 16 ++++++++++++++++ .../data/procedures/MismatchedNamedEnd.tid | 16 ++++++++++++++++ .../data/procedures/WhitespaceOnlyWithEnd.tid | 18 ++++++++++++++++++ .../data/procedures/WhitespaceOnlyWithEnd2.tid | 15 +++++++++++++++ 12 files changed, 168 insertions(+), 6 deletions(-) create mode 100644 editions/test/tiddlers/tests/data/macros/EndInBody.tid create mode 100644 editions/test/tiddlers/tests/data/macros/IndentedEnd.tid create mode 100644 editions/test/tiddlers/tests/data/macros/MismatchedNamedEnd.tid create mode 100644 editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd.tid create mode 100644 editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd2.tid create mode 100644 editions/test/tiddlers/tests/data/procedures/EndInBody.tid create mode 100644 editions/test/tiddlers/tests/data/procedures/IndentedEnd.tid create mode 100644 editions/test/tiddlers/tests/data/procedures/MismatchedNamedEnd.tid create mode 100644 editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd.tid create mode 100644 editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd2.tid diff --git a/core/modules/parsers/wikiparser/rules/fnprocdef.js b/core/modules/parsers/wikiparser/rules/fnprocdef.js index 3f21b8da7..85bd14d5c 100644 --- a/core/modules/parsers/wikiparser/rules/fnprocdef.js +++ b/core/modules/parsers/wikiparser/rules/fnprocdef.js @@ -49,11 +49,11 @@ exports.parse = function() { if(this.match[3]) { params = $tw.utils.parseParameterDefinition(this.match[4]); } - // Is this a multiline definition? + // Is the remainder of the line blank after the parameter close paren? var reEnd; if(this.match[5]) { - // If so, the end of the body is marked with \end - reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg"); + // If so, it is a multiline definition and the end of the body is marked with \end + reEnd = new RegExp("((:?^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[2]) + ")?(?:$|\\r?\\n))","mg"); } else { // Otherwise, the end of the definition is marked by the end of the line reEnd = /($|\r?\n)/mg; diff --git a/core/modules/parsers/wikiparser/rules/macrodef.js b/core/modules/parsers/wikiparser/rules/macrodef.js index 74a94a385..2001f70d5 100644 --- a/core/modules/parsers/wikiparser/rules/macrodef.js +++ b/core/modules/parsers/wikiparser/rules/macrodef.js @@ -54,11 +54,11 @@ exports.parse = function() { paramMatch = reParam.exec(paramString); } } - // Is this a multiline definition? + // Is the remainder of the \define line blank after the parameter close paren? var reEnd; if(this.match[3]) { - // If so, the end of the body is marked with \end - reEnd = new RegExp("(\\r?\\n[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg"); + // If so, it is a multiline definition and the end of the body is marked with \end + reEnd = new RegExp("((?:^|\\r?\\n)[^\\S\\n\\r]*\\\\end[^\\S\\n\\r]*(?:" + $tw.utils.escapeRegExp(this.match[1]) + ")?(?:$|\\r?\\n))","mg"); } else { // Otherwise, the end of the definition is marked by the end of the line reEnd = /($|\r?\n)/mg; diff --git a/editions/test/tiddlers/tests/data/macros/EndInBody.tid b/editions/test/tiddlers/tests/data/macros/EndInBody.tid new file mode 100644 index 000000000..e93a0917d --- /dev/null +++ b/editions/test/tiddlers/tests/data/macros/EndInBody.tid @@ -0,0 +1,16 @@ +title: Macros/EndInBody +description: \end line starting with non-whitespace is part of macro body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\define hello() + hello \end +\end + +Out: <> ++ +title: ExpectedResult + +

Out: hello \end

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/macros/IndentedEnd.tid b/editions/test/tiddlers/tests/data/macros/IndentedEnd.tid new file mode 100644 index 000000000..97f2c4197 --- /dev/null +++ b/editions/test/tiddlers/tests/data/macros/IndentedEnd.tid @@ -0,0 +1,16 @@ +title: Macros/IndentedEnd +description: \end line starting with whitespace ends a macro body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\define hello() + hello \end + \end + +Out: <> ++ +title: ExpectedResult + +

Out: hello \end

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/macros/MismatchedNamedEnd.tid b/editions/test/tiddlers/tests/data/macros/MismatchedNamedEnd.tid new file mode 100644 index 000000000..b66821753 --- /dev/null +++ b/editions/test/tiddlers/tests/data/macros/MismatchedNamedEnd.tid @@ -0,0 +1,16 @@ +title: Macros/MismatchedNamedEnd +description: Mismatched named end is part of the body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\define hello() + \end goodbye +\end + +Out: <> ++ +title: ExpectedResult + +

Out: \end goodbye

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd.tid b/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd.tid new file mode 100644 index 000000000..6998672ba --- /dev/null +++ b/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd.tid @@ -0,0 +1,18 @@ +title: Macros/WhitespaceOnlyWithEnd +description: The /end should be detected when macro definition contains only whitespace +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\define max() +\end +Nothing +\end + +Out: <> ++ +title: ExpectedResult + +

Nothing +\end

Out:

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd2.tid b/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd2.tid new file mode 100644 index 000000000..60db278d6 --- /dev/null +++ b/editions/test/tiddlers/tests/data/macros/WhitespaceOnlyWithEnd2.tid @@ -0,0 +1,15 @@ +title: Macros/WhitespaceOnlyWithEnd2 +description: Line with \end can start with whitespace +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\define empty() + \end + +Out: <> ++ +title: ExpectedResult + +

Out:

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/procedures/EndInBody.tid b/editions/test/tiddlers/tests/data/procedures/EndInBody.tid new file mode 100644 index 000000000..3aa13fad5 --- /dev/null +++ b/editions/test/tiddlers/tests/data/procedures/EndInBody.tid @@ -0,0 +1,16 @@ +title: Procedures/EndInBody +description: \end line starting with non-whitespace is part of procedure body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\procedure hello() + hello \end +\end + +Out: <> ++ +title: ExpectedResult + +

Out: hello \end

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/procedures/IndentedEnd.tid b/editions/test/tiddlers/tests/data/procedures/IndentedEnd.tid new file mode 100644 index 000000000..664be3446 --- /dev/null +++ b/editions/test/tiddlers/tests/data/procedures/IndentedEnd.tid @@ -0,0 +1,16 @@ +title: Procedures/IndentedEnd +description: \end line starting with whitespace ends a procedure body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\procedure hello() + hello \end + \end + +Out: <> ++ +title: ExpectedResult + +

Out: hello \end

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/procedures/MismatchedNamedEnd.tid b/editions/test/tiddlers/tests/data/procedures/MismatchedNamedEnd.tid new file mode 100644 index 000000000..0b5385c6e --- /dev/null +++ b/editions/test/tiddlers/tests/data/procedures/MismatchedNamedEnd.tid @@ -0,0 +1,16 @@ +title: Procedures/MismatchedNamedEnd +description: Mismatched named end is part of the body +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\procedure hello() + \end goodbye +\end + +Out: <> ++ +title: ExpectedResult + +

Out: \end goodbye

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd.tid b/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd.tid new file mode 100644 index 000000000..51f0b87df --- /dev/null +++ b/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd.tid @@ -0,0 +1,18 @@ +title: Procedures/WhitespaceOnlyWithEnd +description: The /end should be detected when procedure definition contains only whitespace +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\procedure max() +\end +Nothing +\end + +Out: <> ++ +title: ExpectedResult + +

Nothing +\end

Out:

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd2.tid b/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd2.tid new file mode 100644 index 000000000..54d3ebbf6 --- /dev/null +++ b/editions/test/tiddlers/tests/data/procedures/WhitespaceOnlyWithEnd2.tid @@ -0,0 +1,15 @@ +title: Procedures/WhitespaceOnlyWithEnd2 +description: Line with \end can start with whitespace +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\procedure empty() + \end + +Out: <> ++ +title: ExpectedResult + +

Out:

\ No newline at end of file From aa4aeb187cb5a885411b612d818f189ba124d23f Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Wed, 24 Jan 2024 12:33:50 +0100 Subject: [PATCH 4/6] Fixes functions to use variables set by filter runs (#7906) * fix: functions should use variables set by filter runs * refactor: code clean up * chore: added more tests --- core/modules/widgets/widget.js | 2 +- .../functions/FunctionFilterrunVariables.tid | 24 +++++++++++++++++++ .../functions/FunctionFilterrunVariables2.tid | 20 ++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables.tid create mode 100644 editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables2.tid diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index af4892b9e..ea300ca0e 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -153,7 +153,7 @@ Widget.prototype.getVariableInfo = function(name,options) { } else if(variable.isFunctionDefinition) { // Function evaluations params = self.resolveVariableParameters(variable.params,actualParams); - var variables = Object.create(null); + var variables = options.variables || Object.create(null); // Apply default parameter values $tw.utils.each(variable.params,function(param,index) { if(param["default"]) { diff --git a/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables.tid b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables.tid new file mode 100644 index 000000000..5226e9f05 --- /dev/null +++ b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables.tid @@ -0,0 +1,24 @@ +title: Functions/FunctionFilterrunVariables +description: Functions in filter runs that set variables +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Idiosyncrasy +caption: Idiosyncrasy Caption Field + ++ +title: Output + +\whitespace trim +\procedure demo-subfilter() [] +\function .demo-function() [] + +<$let currentTiddler="Idiosyncrasy"> +<$text text={{{ [get[caption]!is[blank]else] :map[subfilter] }}}/>, +<$text text={{{ [get[caption]!is[blank]else] :map[.demo-function[]] }}}/> + + ++ +title: ExpectedResult + +

Idiosyncrasy Caption Field,Idiosyncrasy Caption Field

\ No newline at end of file diff --git a/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables2.tid b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables2.tid new file mode 100644 index 000000000..07b8c412a --- /dev/null +++ b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables2.tid @@ -0,0 +1,20 @@ +title: Functions/FunctionFilterrunVariables2 +description: Functions in filter runs that set variables +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Apple +cost: 5 + ++ +title: Output + +\whitespace trim +\function .doublecost() [get[cost]multiply[2]] + +<$text text={{{ [[Apple]] :map[.doublecost[]] }}}/> + ++ +title: ExpectedResult + +10 \ No newline at end of file From bc3d64f4b8c2d69f6d0837069f22025eec52109f Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Wed, 24 Jan 2024 12:37:15 +0100 Subject: [PATCH 5/6] Refresh edit widget when the editor type has changed (#7943) --- core/modules/widgets/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/widgets/edit.js b/core/modules/widgets/edit.js index e7bd49b93..eb7758e90 100644 --- a/core/modules/widgets/edit.js +++ b/core/modules/widgets/edit.js @@ -90,7 +90,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of EditWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); // Refresh if an attribute has changed, or the type associated with the target tiddler has changed - if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (changedTiddlers[this.editTitle] && this.getEditorType() !== this.editorType)) { + if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || (this.getEditorType() !== this.editorType)) { this.refreshSelf(); return true; } else { From 575d80dfe9569729e1d7bbd0db877bd3e2ae2594 Mon Sep 17 00:00:00 2001 From: oeyoews Date: Wed, 24 Jan 2024 19:40:05 +0800 Subject: [PATCH 6/6] Fix Editor preview width #7787 (#7922) --- themes/tiddlywiki/vanilla/base.tid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 214352b23..618afc695 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1589,7 +1589,7 @@ html body.tc-body.tc-single-tiddler-window { grid-template-areas: "toolbar toolbar" "editor preview"; - grid-template-columns: 1fr 1fr; + grid-template-columns: repeat(2, minmax(0px, 1fr)); grid-template-rows: auto 1fr; }