1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-14 13:54:50 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/releasenotes/Release 5.3.0.tid

166 lines
11 KiB
Plaintext
Raw Normal View History

Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
caption: 5.3.0
2023-07-01 11:40:38 +00:00
created: 20230701123439630
modified: 20230701123439630
released: 20230701123439630
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
tags: ReleaseNotes
title: Release 5.3.0
type: text/vnd.tiddlywiki
description: Parameterised transclusions, procedures, functions, custom widgets
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
//[[See GitHub for detailed change history of this release|https://github.com/TiddlyWiki/TiddlyWiki5/compare/v5.2.7...v5.3.0]]//
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
2023-06-30 17:19:26 +00:00
<<.banner-credits
2023-07-01 11:29:33 +00:00
credit:"""Congratulations to [[vilc|https://talk.tiddlywiki.org/u/vilc]] for their winning design for the banner for this release (here is the [[competition thread|https://talk.tiddlywiki.org/t/banner-image-competition-for-v5-3-0/7406/10]]).
2023-06-30 17:19:26 +00:00
"""
url:"https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/04950452fab7d5cb86f893020355611c4711d361/editions/tw5.com/tiddlers/images/New%20Release%20Banner.jpg"
>>
2023-05-06 16:33:19 +00:00
! Overview of v5.3.0
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
2023-05-06 16:33:19 +00:00
This release introduces a number of significant improvements and new features related to some of TiddlyWiki's most fundamental components: macros, widgets, operators and transclusion. v5.3.0 also contains several other bug fixes and improvements.
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
2023-05-06 16:33:19 +00:00
! Introduction to Parameterised Transclusion, Procedures, Functions and Custom Widgets
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
<<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/6666">> The motivation of these changes is to fix one of ~TiddlyWiki 5's early design flaws: the reliance on macros using textual substitution as the primary way to modularise and reuse wikitext and filters.
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
Experience has shown that while macros are a good match for a small number of tasks, they are brittle and error prone for many common operations. See [[Macro Pitfalls]] for a discussion of the problems that accompany this approach. Over the years we have introduced mitigations for the worst problems but these have come at a cost of increased complexity.
The changes in this release provide powerful new ways to achieve common tasks, and unlock completely new capabilities that were previously impossible in wikitext.
* [[Procedures]], which are essentially what macros should have been; they work in exactly the same way except that parameters are exposed as simple variables (without the double underscores) and no textual substitution takes place
* [[Custom Widgets]], allowing the creation of widgets in wikitext, and the redefinition of built-in widgets
* [[Functions]], a new way to encapsulate filter expressions with named parameters, including the ability to make custom filter operators
* Parameterised [[Transclusions|Transclusion]], allowing strings and wikitext trees to be passed to transclusions
The approach taken by this release is to add new functionality by extending and augmenting the system without disturbing existing functionality. All of these changes are thus intended to be backwards compatible. While they represent a new field of opportunities for wikitext authors, it is possible for authors to ignore all these new features and continue to use ~TiddlyWiki 5 in the way that they have always done.
These changes lay the groundwork for macros and related features to be deprecated (which is the point at which users are advised not to use old features, and instead given clear pointers to the equivalent modern functionality).
2023-06-24 14:21:30 +00:00
! Text Substitution Improvements
<<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7526">> The new transclusion architecture is not by itself sufficient to enable us to fully deprecate macros yet. To handle most of the remaining use cases this release adds convenient new ways of using textual substitution without having to create a macro:
2023-06-24 14:21:30 +00:00
Firstly, the new [[text substitution syntax for widget attributes|Substituted Attribute Values]] allows widget attributes to be assigned the value of a string with certain placeholders being replaced by their processed contents. For example:
2023-06-30 15:41:36 +00:00
* Substitute variable names with the value: <$codeblock code="attr=`Current tiddler is $(currentTiddler)$`"/>
* Substitute filter expressions with the first value they return: <$codeblock code="attr=```There are ${ [tag[Done]count[]] }$ completed tasks```"/>
2023-06-24 14:21:30 +00:00
Secondly, the new [[substitute operator|substitute Operator]] allows the same textual substitutions to be performed via a filter operator with the addition of positional parameters that use placeholders of the form `$1$`, `$2$`, `$3$` etc.
```
[[https://$1$/$(currentTiddler)$]substitute<domain-name>]
```
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
2023-06-24 09:51:20 +00:00
! HTTP Requests in WikiText
<<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7422">> new [[WidgetMessage: tm-http-request]] for performing HTTP requests in WikiText. This opens up some exciting new opportunities:
2023-06-24 09:51:20 +00:00
* Integration with Web-based APIs. The documentation includes an [[example of using the Zotero API|WidgetMessage: tm-http-request Example - Zotero]] to retrieve academic citation data
* Dynamic content loading: additional tiddlers can be imported dynamically after the main wiki has loaded
! Defaulting to Disabling CamelCase Links
<<.link-badge-updated "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7513">> CamelCase linking is now disabled by default for new wikis. (Note that this documentation wiki has CamelCase linking explicitly enabled because much of the old content was written relying on them).
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Plugin Improvements
* <<.link-badge-updated "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7554">> Google Analytics plugin to use new GA4 code. Note that the update requires manual configuration to use the new "measurement ID" instead of the old "account ID"
* <<.link-badge-extended "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7260">> Dynannotate pugin to support three additional search modes
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7365">> problem with [[BrowserStorage Plugin]] unnecessarily saving shadow tiddlers
2023-06-24 09:51:20 +00:00
* <<.link-badge-improved "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7398">> [[BrowserStorage Plugin]] to request that browser storage be persisted without eviction
* <<.link-badge-improved "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7493">> [[CodeMirror Plugin]] to add an option to make trailing spaces visible
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Translation improvement
Improvements to the following translations:
2023-06-29 14:46:28 +00:00
* French
2023-06-24 16:53:26 +00:00
* German
* Polish
* Chinese
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Usability Improvements
* <<.link-badge-improved "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7524">> consistency of layout of "Settings" tab in $:/ControlPanel
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
2023-06-30 15:41:36 +00:00
<!--
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Widget Improvements
2023-06-30 15:41:36 +00:00
-->
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Filter improvements
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7511"> new [[deserialize Operator]] for converting various textual representations of tiddlers into JSON data
* <<.link-badge-extended "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7292">> [[format Operator]] to support converting Unix timestamps to TiddlyWiki's native date format
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7392">> new [[':then' filter run prefix|Then Filter Run Prefix]]
2023-06-08 20:18:24 +00:00
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Hackability Improvements
* <<.link-badge-extended "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7413">> [[Core Icons]] to allow the size to be controlled with a parameter
2023-05-06 18:26:42 +00:00
** <<.warning """This change can cause problems with non-standard usage of the core icons where the text is directly rendered instead of being transcluded""">>
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7182">> new [[thisTiddler Variable]] that refers to the tiddler currently being rendered
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7530">> `data-tag-title` attribute to all tag pills, allowing easier [[Custom tag pill styles]]
* <<.link-badge-improved "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7332">> [[Story Tiddler Template Cascade]] handling to fall back to the default template if the output of the cascade is not valid
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7378">> missing file extensions for "audio/mpeg" files
* <<.link-badge-extended "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7417">> [[Table-of-Contents Macros]] to add consistent support for an ''exclude'' parameter
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/commit/190613ad2989f70526f86eef17f524087f60eb72">> [[tv-config-static Variable]] for indicating static rendering
2023-06-24 16:53:26 +00:00
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Bug Fixes
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7215">> importing tiddlers by pasting tiddler data
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7400">> unneeded 14px bottom border for textareas with autoheight enabled
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7380">> crashes when using an invalid CSS selector for [[WidgetMessage: tm-focus-selector]] and [[WidgetMessage: tm-scroll]]
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7401">> bug whereby scrolling occurs if the linkcatcher widget triggers an action-navigate and the $scroll attribute is set to "no"
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7409">> problem switching between LTR and RTL text
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7448">> bug when the listField attribute of the CheckboxWidget was given the name of a date field (like <<.field created>> or <<.field modified>>)
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/issues/7529">> size of buttons in dropdown for editor "link" toolbar button
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/commit/8e132948b6bec623d81d300fbe6dc3a0307bcc6d">> crash when transcluding a lazily loaded tiddler as an attribute value
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/issues/7462">> DiffTextWidget crash with missing or empty attributes
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Node.js Improvements
* <<.link-badge-extended "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7471">> [[WebServer Parameter: authenticated-user-header]] to require URI encoding of authenticated username header, permitting non-ASCII characters in usernames
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7253">> support for `filepath` source attribute to [[tiddlywiki.files Files]]
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/commit/48b22abdaab62c281c207127c66883b50898f9dd">> a warning message for JSON errors in [[tiddlywiki.info Files]] or [[plugin.info Files|PluginFolders]]
* <<.link-badge-added "https://github.com/TiddlyWiki/TiddlyWiki5/pull/7490">> new "explodePlugins" option to SaveWikiFolderCommand
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Performance Improvements
* <<.link-badge-fixed "https://github.com/TiddlyWiki/TiddlyWiki5/pull/4624">> module execution to reuse the same sandbox, saving memory and improving performance
2023-05-06 16:33:19 +00:00
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
! Acknowledgements
[[@Jermolene|https://github.com/Jermolene]] would like to thank the contributors to this release who have generously given their time to help improve TiddlyWiki:
<<.contributors """
2023-06-24 16:53:26 +00:00
AnthonyMuscio
2023-05-06 16:33:19 +00:00
Arlen22
2023-06-08 20:18:24 +00:00
BramChen
2023-05-06 16:33:19 +00:00
btheado
2023-06-24 16:53:26 +00:00
buggyj
2023-06-28 16:55:01 +00:00
carlo-colombo
2023-06-24 16:53:26 +00:00
cdruan
2023-05-06 16:33:19 +00:00
donmor
2023-06-24 16:53:26 +00:00
EvidentlyCube
2023-05-06 16:33:19 +00:00
flibbles
GameDungeon
2023-06-08 20:18:24 +00:00
JoshuaFontany
2023-05-06 16:33:19 +00:00
kookma
linonetwo
Marxsal
2023-06-08 20:18:24 +00:00
mateuszwilczek
2023-05-06 16:33:19 +00:00
michsa
muzimuzhi
2023-06-30 15:41:36 +00:00
oeyoews
2023-05-06 16:33:19 +00:00
pmario
rmunn
2023-05-06 16:33:19 +00:00
saqimtiaz
2023-06-08 20:18:24 +00:00
tavin
twMat
2023-06-29 14:46:28 +00:00
xcazin
2023-05-06 16:33:19 +00:00
yaisog
2023-06-24 16:53:26 +00:00
Zacharia2
Parameterised transclusions (#6666) * Initial commit Everything is draft. * Fix test execution * Fix and test missing target handling * Use the ubertransclude widget for the wikitext transclusion syntax * Changed transclude widget in binary parser to ubertransclude * Add a test for custom action widgets * Don't worry about ordered attributes The changes in 0bffae21088aafc0cdebafe6a5de7907d7c52a3a mean that we don't need to explicitly maintain the ordered attributes * Remove need to explicitly clear widget mapping variable when invoking overridden widget * Use ts- prefix for system slot names * Add a definition for the value widget just so that it doesn't cause errors Of course, it doesn't actually need to be a JS widget, it could be a wikitext widget... * Add support for positional parameters * Ubertransclusion positional parameters should be based on name, not position * Add support for shortcut syntax for positional transclusion parameters * Importvariables should skip parameters widgets * Refactor transclude widget before uberfying it * Refactor ubertransclude functionality into transclude widget * Replace ubertransclude widget with transclude widget * Add wikitext shortcut for new-style function definitions * Allow brackets to be omitted for function definitions with no parameters * Add pragma rule for parameters declarations * Remove erroneous "tag" property * Add support for accessing function parameters as name/value pairs * Be as permissive as possible with parameter names Previously restricted to upper and lower case, digits and dash and underscore * Rewrite some tests to use the shortcut syntaxes * Mustn't allow commas in parameter names * Fix crash when transcluding an undefined variable Thanks @pmario See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1114692359 * Unquoted parameters should not eat a succeeding comma Fixes #6672 * Remove extraneous code * Allow the let widget to create variables starting with $ * Fix addAttributeToParseTreeNode handling of ordered attributes * Reuse attribute objects when executing custom widgets * Fix importing of function definitions * Fix parameter handling * Introduce genesis widget for dynamically creating widgets See the "RedefineLet" test for a contrived example of usage * Change tiddler separator used in wikitext tests Underscore looked ambiguous; I kept typing dashes by accident * Cache parse trees when transcluding variables * Fix bug with empty strings ignored in $tw.utils.stringifyList/parseStringArray I will pull this out into a separate PR. Fixing it doesn't cause problems for the core but I imagine it might cause issues for 3rd party code. * Fixes to enable the transclude widget itself to be overridden There are two big changes here: Replace the previous "ts-wrapper" mechanism, which we had been using to redefine custom widgets inside their definitions to prevent recursive calls. Now we've got the genesis widget we can instead control recursion through a new "$remappable" attribute that allows the custom widget mechanism to be skipped. We also extend the slot widget to allow a depth to be specified; it then reaches up by the indicated number of transclusion widgets to find the one from which it should retrieve the slot value. * Fix genesis widget example * Use enlist:raw to preserve duplicates * Don't create variables with value undefined for missing parameters * Fix variable retrieval bug with test harness * Improve recursion detection While retaining backwards compatibility * Experimental support for custom filter operators Just as we can define custom widgets we can also define custom parameterised filter operators * Add visible transclusions component and demo Very useful to see transclusions explicitly Makes a good demo of a super-complicated widget override. * Genesis widget should pass raw attributes onto child widget... ...so that it can more efficiently handle refreshing itself. * Use consistent parse tree node property for params * Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax * Clarify that the recent changes allow functions to be invoked with the double bracket syntax In other words, the transclude widget distinguishes between functions and macros and handles the parameters appropriately * Make the macrocall widget delegate to the transclude widget * Switch to using \procedure to define new-style macros, and \function for custom filter operator functions I now need to update the OP! * Fix visible transclusion example * Remove obsolete code Left over after refactoring * Better backwards compatibility for legacy recursion marker Fixes the problem with tag dropdowns @btheado * Fix stringifying/parsing string arrays containing newlines A very old bug. Fixes the ActionListOpsWidget problem @btheado * Transclude: replace paramNames/paramValues with more robust JSON payload More details at https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1123719153 * Rename internal "unknown" filter operator so that users cannot invoke it * Detect recursion by tracking widget tree depth The old recursion marker approach was very slow, and didn't catch test cases like editions/test/tiddlers/tests/data/transclude/Recursion.tid * Use \widget for custom widget definitions, and remove need for angle brackets Need to do some refactoring of all those isFunctionDefinition/isProcedureDefinition/isWidgetDefinition flags into a single property * Rename <$value> widget to <$fill> * Require $$ for custom widgets, and that overridden JS widgets must exist See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1133637763 * Fix invocation of JS macros * Experimental update of the parse-tree preview visualisation An experiment to try out using the new JSON operators for rendering the JSON parse tree that we get back from the wikify widget. As usual with these experiments, this one is going to require quite a lot more work to finish up: * The formatting is via direct styles rather than classes * The formatting for attributes and properties is not yet completed * The same thing needs to also be done to the widget tree preview * Procedures and widgets inherit whitespace trim setting from their definition * Missed off 22e7ec23811b137a119295b5ce72bccdc18a697a * Require period prefix for custom filter operator functions To ensure that custom filter operators cannot clash with future core operators. * Allow custom functions to be invoked as attributes * WIP * Remove unneeded test tiddler * Make is[variable] and variables[] operators resilient to fake widgets * Fix importvariables to work with setvariables as well as set (they are aliases) * Add support for $:/tags/Global * Remove accidental commit 6cc99fcbe33da47cfcb1335d0742b16ea1b9ce03 * Add utility function for parsing macro parameter definitions * Introduce true global variables The basic idea is that if we don't find a variable `foo` then we fallback to retrieving the value from the tiddler `$:/global/foo`, if it exists. This allows us to replace the usual importvariables-based mechanism for global definitions, avoiding cluttering up the variable namespace with every macro. In order to permit subprocedures to be overridden, we also introduce a mechanism for conditional definitions: preceding the word definition|procedure|function|widget with a + causes the definition only to occur if the specified variable doesn't already exist. In the next commit we'll apply this mechanism to the tabs macro * Convert the tabs macro into a global So far it appears to be totally backwards compatible... In practice, I think maybe this and the conversion of the other macros should go into a separate subsequent PR. * Change to `?` for conditional definitions * Fix tabs global so it doesn't crash when viewed directly * Test showing how to un-override a core widget * Cleaning up after f63634900724eda937286d946b2e6f65fcf6d503 * Minor cleanups * Clean up unknown filter * Introduce function operator for calling functions Can invoke any functions, not just those start with a period. And can pass zero parameters (in contrast when invoked as a custom filter operator there's no way to omit the first parameter). * Use underscores for new system fields for global variable tiddlers For consistency with `_canonical_uri`; unlike many system fields, the behaviour of these fields is baked into the core JS code. * Refactor $parameters widget The objective is to add a $depth attribute so that it is possible to reach up to retrieve the parameters of ancestor transclusions. However, doing so requires changing the encoding of parameter names so that it is not possible for a user parameter to clash with an attribute like $depth. So now we have to double up dollars on any attribute names seen by the parameters widget, just like with the transclude widget itself. * Fix refreshing of global variables Global variables access within attributes will automatically trigger a refresh if the attribute text changes, but that wasn't happening for transclusions. * Remove support for $:/tags/Global It is not needed now that we have true global variables * Typo from f513b403fe911442bcbaf0628fa47d3d2ed3cf93 * Make slot fill data available to transclusions Allows transcluded content to dynamically process <$fill> widgets within the calling transclusion * Mark docs as v5.3.0 * Simplify metaparameters implementation * Fix typo * Adjust naming of transclusion metaparameter * Fix up handling of slot/fill for custom widgets Previously we were wrapping the body in an implicit `<$fill $name="ts-body">` widget * Add format:json operator I've been finding this useful for debugging, and it kind of goes with the JSON operators * Docs: JSON operators and tweaks to genesis widget * Docs: format:json Also tweak to the behaviour of format:json if the input string is not valid JSON * Fix #6721 * Revert "Fix #6721" This reverts commit b216579255d6e6214f3cf71ab771fcc57240aa74 which was committed to the wrong branch * Fix new selection tracker to return relative coordinates * Make use of type attribute consistent * Docs: Transclude widget * Simplify the fill widget We can rely on the default processing in the base class * Slot widget: be more defensive about negative depth values * Parameters widget: Be defensive about negative depths * Protect against excessively recursive functions * FIx transcluding of functions This first implementation concatenates the results of the filter (with no separator) and then wikifies the result. The test in this commit is quite interesting... * Tweak semantics of JSON operators to match #6932 This allows us to later bring in the optimisations without breaking backwards compatibility. * Revert obsolete changes to boot.js * Fix inadvertent whitespace change * Remove tests related to obsolete changes to boot.js Should have been part of 2f494ba15246edd356bfc591b0115d30592e7eb8 * Revert changes to parse tree preview This implementation requires #6666 * Add test to show that global widgets need not use the _parameters field * Disable overriding core widgets in safe mode * Coding style tweak * More comments * Fix caching of parse variables/macros/procedures * Transcluded functions should operate on the entire store * Refactor filter recursion detection to avoid an unneeded wrapper function * Fix error in 25312b3e3218c1002c483a1fc995d2b65509b993 * WIP * Revert "WIP" This reverts commit 8654dfc679ea12d30ffd8b14a30165d826be06b7. * When transcluding functions, pass an empty item list to the filter, and just return the first item * Rejig genesis widget to be easier to use * Parameters widget: protect against negative $depth * Docs updates * Docs updates * Tweak comments * Add custom view template body for globals, and a new sidebar tab under "more" And also a custom view template title that greys out the $:/global/ part of the title * Update function operator to return the input list if the function is missing * Remove negation from function operator This implementation was not useful. * Tests and docs for function operator * Docs tweaks * Improve indentation See https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r967655251 * Missing tests for parameters widget * Fix visible transclude * Docs update * Docs typo * Huge Documentation Update Not quite finished, but definitely on the home stretch * Slight optimisation to user defined widgets * Remove implementation of $:/globals/ Performance with this implementation is inherently poor because of the need to perform a wiki lookup for each child widget created. * Docs clarification * Docs update * Some widget.js cleanups * Remove support for conditional definitions It was introduced for use cases associated with the global mechanism that was dropped in e3d13696c887ba849958c8980623d8ff45bb8a36 * Docs updates * Revert change to setwidget docs * Docs update * Docs updates * Clarify/simplify some tests * More docs updates * Fix doc file locations * Docs updates * Revert modified date of docs that have only had minor tweaks * Docs typo https://github.com/Jermolene/TiddlyWiki5/pull/6666#discussion_r990811220 Thanks @btheado * Transcluding functions: fix missing parameters passed as undefined Thanks @btheado – see https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1276187372 * Parameter parenthesis should be mandatory in function/procedure/widget definitions See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387 * Attempt to build this branch with CI * Add release note etc for 5.3.0 * Temporary new release banner for v5.3.0 * New New Release Banner * New test for undefined parameters * Adjust modified times of docs tiddlers to make them easier to find * Update release note * Add parenthesis to the visible transclusion definition Parenthesis were made mandatory in 5194b24108efda6da95daf4261ffd80473073a65 Fixes #6998 * Fix macrocall refresh issue It turns out that this.transcludeTitle is always truthy, even if we are transcluding a variable Fixes #7001 * Filter run prefixes should use widget.makeFakeWidgetWithVariables * Docs typo Thanks @twMat * Docs: clarify function operator invocation See discussion at https://github.com/Jermolene/TiddlyWiki5/issues/6991#issuecomment-1301703599 * Docs: Update \define pragma to cover named ends * Docs: move tiddlers to correct directory * Add support for named end markers for procedures, functions and widgets * Docs note about nested macro definitions * Rename test * Fix detection of empty transclusions See https://talk.tiddlywiki.org/t/exploring-default-tiddler-links-hackability-in-v5-3-0/5745/25?u=jeremyruston * New test missed off a45349cc996390192114fed486bfa6900da641d7 * Refactor wikified function tests * Refactor function invocation * Introduce new widget helper function to evaluate variables.Functions are evaluated as parameterised filter strings, macros as text with textual substitution of parameters and variables, and procedures and widgets as plain text * Refactor the function operator and unknown operator to use the new helper * Use the new helper to evaluate variables within filter strings, thus fixing a bug whereby functions called in such a way were being returned as plain text instead of being evaluated * Refactor the transclude widget to use the new helper * Update tests * Fix positional parameters in widget.evaluateVariable() This should clear up the remaining anomalies in #7009, let me know how you get on @btheado * Remove 5.2.8 release note * Fix nonstandard initialisation code for fill/parameter/slot widgets * Update modification times of doc tiddlers So that they are at the top of the recent tab * Update 5.3.0 release note * Remove custom CI step for this branch * Restore standard sitetitle
2023-04-19 10:55:25 +00:00
""">>